def main(): defaultTarget = '.' defaultUmask = 0o022 if settingsAvailable: defaultTarget = settings.TARGET defaultUmask = settings.UMASK parser = argparse.ArgumentParser(description='Work with recipe markdown files') parser.add_argument('-s', metavar='source', help='source of data', default='.') parser.add_argument('-t', metavar='target', help='target for processed outputs', default=defaultTarget) parser.add_argument('-i', help='do not reprocess, build index', default=None, action='store_true') parser.add_argument('-j', help='do not reprocess, build metadata json', default=None, action='store_true') args = parser.parse_args() if args.t is None: print('no target specified via command line or config file') return 1 if args.i is None and args.j is None: reprocess(args.t, args.s, defaultUmask) target = args.t + '/' if args.i or args.i is None: print('building html index') index.update_index(target) if args.j or args.j is None: print('building json index') index.update_json(target) return 0
def update(): subject = request.args.get('subject') if subject is None: utils.save_update_start_time() clusters = cluster.update_clusters() utils.save_clusters(clusters) uri2rank = pagerank.update_pagerank() utils.save_uri2rank(uri2rank) index.update_index(utils.get_uri2rank()) query.memoized_query_sparql.cache_clear() utils.log('Cache cleared') utils.save_update_end_time() success_message = 'Successfully updated entire index' else: index.refresh_index(subject, utils.get_uri2rank()) success_message = 'Successfully refreshed: ' + subject utils.log(success_message) return success_message
def main(): os.umask(settings.UMASK) print('starting processing of all recipes') clean_output_dir() files = git.ls_tree('HEAD') # do a dry run to catch errors for f in files: file = ' '.join(f[3:]) obj_id = f[2] if file.split('.')[-1] != 'rmd': continue r = process(obj_id,'/dev/null') # do a real run for f in files: file = f[3] obj_id = f[2] if file.split('.')[-1] != 'rmd': continue print('P {}'.format(file)) process(obj_id, xml_filename(file)) index.update_index(settings.TARGET) print('finished processing of commits')
def run(self): if self.files is not None or self.directory is not None: if self.directory is not None: index.index_directory(self.directory, self.output_stream) elif self.files is not None: for f in self.files: index.index_file(path=f, output_stream=self.output_stream) index.update_index() tkMessageBox.showinfo( "Indexacion completada!!!", "Indexacion completada! Puede cerrar la ventana de indexacion" )
def run(self): if self.files is not None or self.directory is not None: if self.directory is not None: index.index_directory(self.directory, self.output_stream) elif self.files is not None: for f in self.files: index.index_file(path=f, output_stream=self.output_stream) index.update_index() tkMessageBox.showinfo( 'Indexacion completada!!!', 'Indexacion completada! Puede cerrar la ventana de indexacion' )
def main(): os.umask(settings.UMASK) (ref, old, new) = sys.argv[1:4] print('starting processing of commit') cf = git.changed_files(old, new) # do a dry run to catch errors for f in cf: action = f[4] file = f[5] obj_id = f[3] if file.split('.')[-1] != settings.EXTENSION: continue if action == 'M' or action == 'A' or action == 'C': r = common.process(obj_id, '/dev/null', settings.XSLT) # do a real run for c in cf: action = c[4] file = c[5] obj_id = c[3] if file.split('.')[-1] != settings.EXTENSION: continue filename = common.xml_filename(file, settings.TARGET) if action == 'D': print('D {}'.format(file)) try: os.remove(filename) except FileNotFoundError: print( 'file to be removed, but could not be found'.format(file)) elif action == 'M' or action == 'A' or action == 'C': print('C {}'.format(file)) common.process(obj_id, filename, settings.XSLT) else: print('unknown git status {} of <{}>'.format(action, file), file=sys.stderr) index.update_index(settings.TARGET) index.update_json(settings.TARGET) print('finished processing of commits')
def main(): os.umask(settings.UMASK) (ref,old,new) = sys.argv[1:4] print('starting processing of commit') cf = git.changed_files(old,new) # do a dry run to catch errors for f in cf: action = f[4] file = f[5] obj_id = f[3] if file.split('.')[-1] != settings.EXTENSION: continue if action == 'M' or action == 'A' or action == 'C': r = common.process(obj_id, '/dev/null', settings.XSLT) # do a real run for c in cf: action = c[4] file = c[5] obj_id = c[3] if file.split('.')[-1] != settings.EXTENSION: continue filename = common.xml_filename(file, settings.TARGET) if action == 'D': print('D {}'.format(file)) try: os.remove(filename) except FileNotFoundError: print('file to be removed, but could not be found'.format(file)) elif action == 'M' or action == 'A' or action == 'C': print('C {}'.format(file)) common.process(obj_id, filename, settings.XSLT) else: print('unknown git status {} of <{}>'.format(action, file), file=sys.stderr) index.update_index(settings.TARGET) index.update_json(settings.TARGET) print('finished processing of commits')
def main(): defaultTarget = '.' defaultUmask = 0o022 if settingsAvailable: defaultTarget = settings.TARGET defaultUmask = settings.UMASK parser = argparse.ArgumentParser( description='Work with recipe markdown files') parser.add_argument('-s', metavar='source', help='source of data', default='.') parser.add_argument('-t', metavar='target', help='target for processed outputs', default=defaultTarget) parser.add_argument('-i', help='do not reprocess, build index', default=None, action='store_true') parser.add_argument('-j', help='do not reprocess, build metadata json', default=None, action='store_true') args = parser.parse_args() if args.t is None: print('no target specified via command line or config file') return 1 if args.i is None and args.j is None: reprocess(args.t, args.s, defaultUmask) target = args.t + '/' if args.i or args.i is None: print('building html index') index.update_index(target) if args.j or args.j is None: print('building json index') index.update_json(target) return 0
async def on_message(message): global xkcd_refs, xkcd_index if not message.content.startswith(wame_config['prefix']): if Wame.user.mentioned_in(message) and not message.mention_everyone \ and not len(message.content.split("@here")) > 1 \ and len(message.mentions) == 1: await Wame.send_message \ (message.channel, embed = wame_help) else: args = await CLIENT.parse_args(message.content, wame_config['prefix']) command = args[0] args = args[1:] logging.info ('\nFull mess: {}\nCommand : {}\nArgs : {}'\ .format (message.content, command, args)) if command == 'xkcd': tmp = await Wame.send_message(message.channel, 'Searching...') if len(args) is 0: embed_comic = await CLIENT.random_embed(xkcd_refs) await Wame.edit_message(tmp, ' ', embed=embed_comic) else: result = await CLIENT.search \ (' '.join(args), xkcd_index, xkcd_refs, blk_list) # 0 == comic found if result['status'] == 0: # Create embed embed_comic = await \ CLIENT.create_embed (result['comic']) await Wame.edit_message(tmp, ' ', embed=embed_comic) else: # It hasn't been found, too bad not_found = discord.Embed (description = "_I found nothing. I'm so sawry and sad :(_. \ \nReply with **`random`** for a surprise\n" , \ colour = (0x000000)) await Wame.edit_message(tmp, " ", embed=not_found) msg = await Wame.wait_for_message \ (author = message.author, \ content = "random", timeout = 20) if (msg): embed_comic = await CLIENT.random_embed(xkcd_refs) await Wame.send_message \ (message.channel, embed = embed_comic) else: await Wame.edit_message(tmp, "Timeout") elif command == 'random': embed_comic = await CLIENT.random_embed(xkcd_refs) await Wame.send_message(message.channel, embed=embed_comic) elif command == 'latest': online_latest = await CLIENT.get_online_xkcd() if online_latest['status'] is 0: embed_comic = await \ CLIENT.create_embed(online_latest) else: local_latest = xkcd_refs[str( max(map(lambda x: int(x), xkcd_refs.keys())))] embed_comic = await \ CLIENT.create_embed (local_latest) await Wame.send_message(message.channel, embed=embed_comic) elif command == 'report': bug_channel = Wame.get_channel(wame_config['report_channel']) embed_report = await CLIENT.report_embed (message, \ {'type': 'User', 'color': (0xff0000), 'client': Wame}) report = await Wame.send_message(bug_channel, embed=embed_report) await Wame.pin_message(report) elif command == 'update': from update_references import update_ref from index import update_index update_ref() xkcd_refs = CLIENT.loadJson(REF) update_index() xkcd_index = CLIENT.loadJson(INDEX) local_latest = xkcd_refs[str( max(map(lambda x: int(x), xkcd_refs.keys())))] embed_comic = await \ CLIENT.create_embed (local_latest) await Wame.send_message(message.channel, embed=embed_comic) elif command == 'help': await Wame.send_message (message.channel, \ embed = wame_help)
ids.append(c['data']['id']) if len(ids) > 100: ids.pop(0) post = c["data"] title = post["title"] tag_list = tagger.make_tags(title) post["tokens"] = tag_list posts.insert(post) if "created_utc" in post: id_date.insert({ post["id"]:post["created_utc"] }) print "Added", post['id'] index.update_index(post["id"], tag_list) time.sleep(10) def main(): index = open('index.txt','w') conn = Connection() coll = conn["reddit"] posts = coll["posts"] id_date = coll["ids"] get_reddit_json(index, posts, id_date) index.close() return if __name__ == '__main__': main()