def from_argparser(klass, args, api=None): if api is None: api = API.from_argparser(args) if args.lang: tags = args.lang.split(",") for tag in tags: if tag not in lang.get_internal_tags(): # FIXME: more elegant solution raise Exception("{} is not a valid language tag".format(tag)) langnames = {lang.langname_for_tag(tag) for tag in tags} else: langnames = set() interactive = args.interactive if klass.force_interactive is False else True return klass(api, interactive=interactive, dry_run=args.dry_run, first=args.first, title=args.title, langnames=langnames)
def from_argparser(klass, args, api=None, db=None): if api is None: api = API.from_argparser(args) if db is None: db = Database.from_argparser(args) if args.lang: tags = args.lang.split(",") for tag in tags: if tag not in lang.get_internal_tags(): # FIXME: more elegant solution raise Exception("{} is not a valid language tag".format(tag)) langnames = {lang.langname_for_tag(tag) for tag in tags} else: langnames = set() return klass(api, db, interactive=args.interactive, dry_run=args.dry_run, first=args.first, title=args.title, langnames=langnames, connection_timeout=args.connection_timeout, max_retries=args.connection_max_retries)
def from_argparser(klass, args, api=None, db=None): if api is None: api = API.from_argparser(args) if db is None: db = Database.from_argparser(args) if args.lang: tags = args.lang.split(",") for tag in tags: if tag not in lang.get_internal_tags(): # FIXME: more elegant solution raise Exception("{} is not a valid language tag".format(tag)) langnames = {lang.langname_for_tag(tag) for tag in tags} else: langnames = set() return klass(api, db, first=args.first, title=args.title, langnames=langnames, connection_timeout=args.connection_timeout, max_retries=args.connection_max_retries)
def from_argparser(klass, args, api=None): if api is None: api = API.from_argparser(args) return klass(api, args.aurpkgs_url, args.tmp_dir, args.ssl_verify, args.report_dir, args.report_page, args.interactive)
logger.info("Plotting hist_active_users.png") hist_active_users = [] num_bins = len(bin_edges) - 1 for i in range(num_bins): # array of indexes for revisions in current bin current_bin, = np.where(bin_indexes == i) active_users = list(set([revisions[ii]["user"] for ii in current_bin])) hist_active_users.append(len(active_users)) plot_date_bars(hist_active_users, bin_edges, title="ArchWiki active users per month", ylabel="active users", fname="stub/hist_active_users.png") if __name__ == "__main__": import ws.config import ws.logging argparser = ws.config.getArgParser(description="Create histogram charts for the statistics page") API.set_argparser(argparser) # TODO: script-specific arguments (e.g. output path) args = argparser.parse_args() # set up logging ws.logging.init(args) api = API.from_argparser(args) db = ws.cache.AllRevisionsProps(api, args.cache_dir) create_histograms(db["revisions"])
def plot_save(fname): plt.savefig(fname, dpi=192) if __name__ == "__main__": import ws.config argparser = ws.config.getArgParser() API.set_argparser(argparser) Database.set_argparser(argparser) args = ws.config.parse_args(argparser) api = API.from_argparser(args) require_login(api) db = Database.from_argparser(args) users = [ "Alad", "Fengchao", "Indigo", "Kynikos", "Lahwaacz", "Lonaowna", "Nl6720" ] all_logs = list(db.query(list="logevents", letype="rights", ledir="newer")) ax = plot_setup() lines = [] for user in users: revs = list( db.query(list="allrevisions",
def from_argparser(klass, args, api=None): if api is None: api = API.from_argparser(args) return klass(api, args.cache_dir, args.page_name, args.days, args.min_edits)
def from_argparser(klass, args, api=None, db=None): if api is None: api = API.from_argparser(args) if db is None: db = Database.from_argparser(args) return klass(api, db, args)
def from_argparser(klass, args, api=None, db=None): if api is None: api = API.from_argparser(args) if db is None: db = Database.from_argparser(args) return klass(api, db, args.page_name, args.days, args.min_edits)
def from_argparser(klass, args, api=None): if api is None: api = API.from_argparser(args) return klass(api, args)
def from_argparser(klass, args, api=None): if api is None: api = API.from_argparser(args) return klass(api, args.spam_phrases, args.spam_occurrences_threshold, args.interactive)