def available_options(self, ignore_overridden_opts=False): cda = algs.get(self.name) options = { } # Iterate in order from parent classes (object) to concrete CD # class. for baseclass in reversed(cda.__mro__): # If an option is set (overridden) in a child class, but # was documented in a parent class, then that means that # this is an explicitely overridden option, and should not # be considered free for modification. In this case, # remove it from the options we are returning as # modifiable. if ignore_overridden_opts: for name in tuple(options): if name in baseclass.__dict__: del options[name] # if baseclass.__doc__: options.update(utils.parse_cda_docstring(baseclass)) #options.update(utils.cda_find_options(cda)) for name, data in options.items(): # copy so we can delete if name.startswith('_'): del options[name] if name in utils.excluded_options: del options[name] data['initial'] = getattr(cda, name) data['doc'] += ' (default: %s)'%(data['initial'], ) return options
def get_cddoc(self, html=False): cda = algs.get(self.name) cddoc = [ ] for baseclass in cda.__mro__: if baseclass.__name__ == 'CDMethod': break if baseclass.__doc__: doc = baseclass.__doc__ # split docstring by "..." in its own paragraph. doc = re.split(r'\n+[ \t]*\n+[ \t]*...\n[ \t]*\n', doc)[0] doc = utils.dedent(doc.strip()).strip() if html: escape(doc) doc = re.sub(r'((https?|ftps?)://[^\s]+[^\s\.,])', r'<a href=\1>\1</a>', doc) doc = mark_safe(doc) cddoc.append((baseclass.__name__, doc)) return cddoc
def _run(self): self.clean_dir() if not os.path.exists(self.basedir): os.mkdir(self.basedir) # Initialize cda = algs.get(self.name) g = self.ds.get_networkx() self.state = 'R' self.save() # Do actual running self.rtime = utcnow() start_time = time.time() cd = cda(g, dir=self.basedir, verbosity=-10, **self.options_dict) self.dtime = utcnow() self.runtime = time.time() - start_time # Process results self.save_results(cd.results) self.state = 'D' self.save() data = { } data['results'] = cd.results data['stdout'] = None return data