From 962d9a7e98f66d8d25a03f49b93510ee245d8fab Mon Sep 17 00:00:00 2001 From: bootje Date: Mon, 4 Mar 2019 22:04:38 +0100 Subject: [PATCH] annotated reader 19-03-04 --- annotated-reader/.DS_Store | Bin 0 -> 6148 bytes annotated-reader/README.md | 0 annotated-reader/annotated-reader.py | 199 +++++++++++++++++++++++++++ annotated-reader/output/.DS_Store | Bin 0 -> 6148 bytes annotated-reader/style.css | 33 +++++ annotated-reader/test.py | 17 +++ annotated-reader/text.txt | 18 +++ archive-bot/.DS_Store | Bin 8196 -> 6148 bytes 8 files changed, 267 insertions(+) create mode 100644 annotated-reader/.DS_Store create mode 100644 annotated-reader/README.md create mode 100644 annotated-reader/annotated-reader.py create mode 100644 annotated-reader/output/.DS_Store create mode 100644 annotated-reader/style.css create mode 100644 annotated-reader/test.py create mode 100644 annotated-reader/text.txt diff --git a/annotated-reader/.DS_Store b/annotated-reader/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..5008ddfcf53c02e82d7eee2e57c38e5672ef89f6 GIT binary patch literal 6148 zcmeH~Jr2S!425mzP>H1@V-^m;4Wg<&0T*E43hX&L&p$$qDprKhvt+--jT7}7np#A3 zem<@ulZcFPQ@L2!n>{z**++&mCkOWA81W14cNZlEfg7;MkzE(HCqgga^y>{tEnwC%0;vJ&^%eQ zLs35+`xjp>T0') + new_html.write('
') + for line in lines: + new_html.write('

{} {}

'.format(x, x, x, x, x, line)) + x = x + 1 + + new_html.write('
') + print('I wrote a new file!', output_html) + + +def insert_comment_at_line(output_html,comment,line_number): + with open (output_html,'r') as f: + text = f.read() + html = BeautifulSoup(text,'html.parser') + div_id = 'linenum-{}'.format(line_number) + line = html.find('div',{'id' : div_id}) + print(line,comment,'#'+str(line_number)+'#') + print(div_id) + + if line: + with open (output_html,'w') as f: + new_comment = html.new_tag("comment") + new_comment.string = comment + line.append(new_comment) + f.write(html.decode()) + +def insert_media_at_line(output_html,mediafile,line_number): + with open (output_html,'r') as f: + text = f.read() + html = BeautifulSoup(text,'html.parser') + div_id = 'linenum-{}'.format(line_number) + line = html.find('div',{'id' : div_id}) + + if line: + #notes to self write function to the detect media type + with open (output_html,'w') as f: + new_image = html.new_tag("img", src = mediafile) + line.append(new_image) + f.write(html.decode()) + +class MUCBot(slixmpp.ClientXMPP): + def __init__(self, jid, password, room, nick, output): + + slixmpp.ClientXMPP.__init__(self, jid, password) + + self.room = room + self.nick = nick + self.output = output + self.current_line = 0 + + self.add_event_handler("session_start", self.start) # moment that it logs on + self.add_event_handler("groupchat_message", self.muc_message) # moment that someone start speaking someone + + output = self.output + if not os.path.exists(output): + os.mkdir(output) + + make_numbered_text('text.txt','annotated-reader.html') + + + def start(self, event): + + self.get_roster() + self.send_presence() + + # https://xmpp.org/extensions/xep-0045.html + self.plugin['xep_0045'].join_muc(self.room, + self.nick, + # If a room password is needed, use: + # password=the_room_password, + wait=True) + + def muc_message(self, msg): + + # Always check that a message is not the bot itself, otherwise you will create an infinite loop responding to your own messages. + if msg['mucnick'] != self.nick: + + # Check if an OOB URL is included in the stanza (which is how an image is sent) + # (OOB object - https://xmpp.org/extensions/xep-0066.html#x-oob) + if len(msg['oob']['url']) > 0: + # UPLOADED IMAGE + # Send a reply + self.send_message(mto=msg['from'].bare, + mbody="Really? Oke. I'll add your photo for you, {}.".format(msg['mucnick']), + mtype='groupchat') + + # Save the image to the output folder + url = msg['oob']['url'] # grep the url in the message + # urlunquote is like url to filename + filename = os.path.basename(urlunquote(url)) # grep the filename in the url + output = self.output + # if not os.path.exists(output): + # os.mkdir(output) + output_path = os.path.join(output, filename) + + u = urllib.request.urlopen(url) # read the image data + new_html = open(output_path, 'wb') # open the output file + new_html.write(u.read()) # write image to file + new_html.close() # close the output file + + # Add image to stream + img = output_path + insert_media_at_line('annotated-reader.html',img,self.current_line) + + else: + # TEXT MESSAGE + for word in msg['body'].split(): + if word.startswith("#line"): + self.current_line = int(word[5:]) + self.send_message(mto=msg['from'].bare, + mbody="I've set the current line number to {}.".format(self.current_line), + mtype='groupchat') + + elif word == "#comment": + self.send_message(mto=msg['from'].bare, + mbody="Really? Oke. I'll add your comment that for you, {}.".format(msg['mucnick']), + mtype='groupchat') + + insert_comment_at_line('annotated-reader.html',msg['body'], self.current_line) + + +if __name__ == '__main__': + # Setup the command line arguments. + parser = ArgumentParser() # making your own command line - ArgumentParser. + + # output verbosity options. + parser.add_argument("-q", "--quiet", help="set logging to ERROR", + action="store_const", dest="loglevel", + const=logging.ERROR, default=logging.INFO) + parser.add_argument("-d", "--debug", help="set logging to DEBUG", + action="store_const", dest="loglevel", + const=logging.DEBUG, default=logging.INFO) + + # JID and password options. + parser.add_argument("-j", "--jid", dest="jid", # jid = user + help="JID to use") + parser.add_argument("-p", "--password", dest="password", + help="password to use") + parser.add_argument("-r", "--room", dest="room", + help="MUC room to join") + parser.add_argument("-n", "--nick", dest="nick", + help="MUC nickname") # MUC = multi user chat + + # output folder for images + parser.add_argument("-o", "--output", dest="output", + help="output folder, this is where the files are stored", + default="./output/", type=str) + + args = parser.parse_args() + + # Setup logging. + logging.basicConfig(level=args.loglevel, + format='%(levelname)-8s %(message)s') + + if args.jid is None: + args.jid = input("User: ") + if args.password is None: + args.password = getpass("Password: ") + if args.room is None: + args.room = input("MUC room: ") + if args.nick is None: + args.nick = input("MUC nickname: ") + if args.output is None: + args.output = input("Output folder: ") + + # Setup the MUCBot and register plugins. Note that while plugins may + # have interdependencies, the order in which you register them does + # not matter. + xmpp = MUCBot(args.jid, args.password, args.room, args.nick, args.output) + xmpp.register_plugin('xep_0030') # Service Discovery + xmpp.register_plugin('xep_0045') # Multi-User Chat + xmpp.register_plugin('xep_0199') # XMPP Ping + xmpp.register_plugin('xep_0066') # Process URI's (files, images) + + # Connect to the XMPP server and start processing XMPP stanzas. + xmpp.connect() + xmpp.process() + diff --git a/annotated-reader/output/.DS_Store b/annotated-reader/output/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..5008ddfcf53c02e82d7eee2e57c38e5672ef89f6 GIT binary patch literal 6148 zcmeH~Jr2S!425mzP>H1@V-^m;4Wg<&0T*E43hX&L&p$$qDprKhvt+--jT7}7np#A3 zem<@ulZcFPQ@L2!n>{z**++&mCkOWA81W14cNZlEfg7;MkzE(HCqgga^y>{tEnwC%0;vJ&^%eQ zLs35+`xjp>T0{}{}'.format(x, x, line)) + + x = x + 1 + +new_html.close() \ No newline at end of file diff --git a/annotated-reader/text.txt b/annotated-reader/text.txt new file mode 100644 index 0000000..20f7a68 --- /dev/null +++ b/annotated-reader/text.txt @@ -0,0 +1,18 @@ +INTRODUCTION: SUBCULTURE AND STYLE + +I managed to get about twenty photographs, and with bits of chewed bread I pasted them on the back of the cardboard sheet of regulations that hangs on the wall. Some are pinned up with bits of brass wire which the foreman brings me and on which I have to string coloured glass beads. Using the same beads with which the prisoners next door make funeral wreaths, I have made star-shaped frames for the most purely criminal. In the evening, as you open your window to the street, I turn the back of the regulation sheet towards me. Smiles and sneers, alike inexorable, enter me by all the holes I offer.... They watch over my little routines. (Genet, 1966a) + +IN the opening pages of The Thief’s Journal, Jean Genet describes how a tube of vaseline, found in his possession, is confiscated by the Spanish police during a raid. This ‘dirty, wretched object’, proclaiming his homosexuality to the world, becomes for Genet a kind of guarantee – ‘the sign of a secret grace which was soon to save me from contempt’. The discovery of the vaseline is greeted. + +2 SUBCULTURE: THE MEANING OF STYLE + +with laughter in the record-office of the station, and the police ‘smelling of garlic, sweat and oil, but... strong in their moral assurance’ subject Genet to a tirade of hostile innuendo. The author joins in the laughter too (‘though painfully’) but later, in his cell, ‘the image of the tube of vaseline never left me’. +I was sure that this puny and most humble object would hold its own against them; by its mere presence it would be able to exasperate all the police in the world; it would draw down upon itself contempt, hatred, white and dumb rages. (Genet, 1967) +I have chosen to begin with these extracts from Genet because he more than most has explored in both his life and his art the subversive implications of style. I shall be returning again and again to Genet’s major themes: the status and meaning of revolt, the idea of style as a form of Refusal, the elevation of crime into art (even though, in our case, the ‘crimes’ are only broken codes). Like Genet, we are interested in subculture – in the expressive forms and rituals of those subordinate groups – the teddy boys and mods and rockers, the skinheads and the punks – who are alternately dismissed, denounced and canonized; treated at different times as threats to public order and as harmless buffoons. Like Genet also, we are intrigued by the most mundane objects – a safety pin, a pointed shoe, a motor cycle – which, none the less, like the tube of vaseline, take on a symbolic dimension, becoming a form of stigmata, tokens of a self-imposed exile. Finally, like Genet, we must seek to recreate the dialectic between action and reaction which renders these objects meaningful. For, just as the conflict between Genet’s ‘unnatural’ sexuality and the policemen’s ‘legitimate’ outrage can be encapsulated in a single object, so the tensions between dominant and subordinate groups can be +found reflected in the surfaces of subculture – in the + +INTRODUCTION: SUBCULTURE AND STYLE 3 + +styles made up of mundane objects which have a double meaning. On the one hand, they warn the ‘straight’ world in advance of a sinister presence – the presence of difference – and draw down upon themselves vague suspicions, uneasy laughter, ‘white and dumb rages’. On the other hand, for those who erect them into icons, who use them as words or as curses, these objects become signs of forbidden identity, sources of value. Recalling his humiliation at the hands of the police, Genet finds consolation in the tube of vaseline. It becomes a symbol of his ‘triumph’ – ‘I would indeeed rather have shed blood than repudiate that silly object’ (Genet, 1967). +The meaning of subculture is, then, always in dispute, and style is the area in which the opposing definitions clash with most dramatic force. Much of the available space in this book will therefore be taken up with a description of the process whereby objects are made to mean and mean again as ‘style’ in subculture. As in Genet’s novels, this process begins with a crime against the natural order, though in this case the deviation may seem slight indeed – the cultivation of a quiff, the acquisition of a scooter or a record or a certain type of suit. But it ends in the construction of a style, in a gesture of defiance or contempt, in a smile or a sneer. It signals a Refusal. I would like to think that this Refusal is worth making, that these gestures have a meaning, that the smiles and the sneers have some subversive value, even if, in the final analysis, they are, like Genet’s gangster pin-ups, just the darker side of sets of regulations, just so much graffiti on a prison wall. +Even so, graffiti can make fascinating reading. They draw attention to themselves. They are an expression both of impotence and a kind of power – the power to disfigure (Norman Mailer calls graffiti – ‘Your presence on their Presence... hanging your alias on their scene’ (Mailer, 1974)). In this book I shall attempt to decipher the graffiti. diff --git a/archive-bot/.DS_Store b/archive-bot/.DS_Store index cfbb97711878b78d7b281e5f8a034cc4b44a63ca..5e3a412786d7aaccea10e51e80f46baed2a1a4f6 100644 GIT binary patch delta 104 zcmZp1XfcprU|?W$DortDU=RQ@Ie-{MGqg`E6q~50$jCS`z?zY9GLL}$#xfiB#q1m$ rg3KU!pfYYC;R?j<8wo#pAR#qNZ;)72B~gp3E-FQ#EV@H7f(4+|ZUV97dLqZEDIv%k z?f~3?qi_Q5!3E%(KLp2VR#YfTW~7;KGV?u0^V5v&mk<$akGf5wIuTi@LTfkCTv5cl zsB>jQkKBba#1jQ{K|Sh_Pkhd81`Gj1zz{G53;{!683^E+EsC|^xvyqTYX}$uYe_)d zA8b^iEv=bSdFwzUQvhfg!?K`{JV3_ST3cE(r7{%PRM`X5p-iV3Ooe0K7ItV$Yo=6% z6I0>D^fxn|p)mRFh_j`gSWBsC4FN-7o`A^RZ<9wcol$=#e@|$a26TB6@-si=K78V6 z9is03k_A1YEqa4oKcp`5{&?2QwlV*Ck=IX$1AX1^{vZs7Nu%+DZIsHJTQ@ALYE^Gl zU%P#tx`~&JhHWo?DLy^*lD@C|&o~dKeb0X$^wLi4-eVpmUJ&(S860$bu)KN^L|vY? z`6%iR<#k*&VObTc(y7(QW5;Ri*n3WMvSW`A4$$A;9KONOSo?_jqbKKkd~rXdv2Y*Gp|u{f4j?3_HFoO8(# zUE6`oEwO;9Brz2Z7yE?6l}DsqONQqfcaYdCX#ouwn6l~wN@{_1k^etg{QLi^V=(J8 z1lF1WD<8YZZ6NsbUR$Iga%~&+6jc=A%aqCxG%_8B%5)q${lgG_8&(n1(wZs72+Du| WA>i-pxOx7AzlLC*|8h63PxBkdF8)9O