rem stringlengths 0 322k | add stringlengths 0 2.05M | context stringlengths 8 228k |
|---|---|---|
def dispatch_visit(self, node, method_name): method = getattr(self, 'visit_' + method_name, self.unknown_visit) | def dispatch_visit(self, node): node_name = node.__class__.__name__ method = getattr(self, 'visit_' + node_name, self.unknown_visit) self.document.reporter.debug( 'calling %s for %s' % (method.__name__, node_name), category='nodes.NodeVisitor.dispatch_visit') | def dispatch_visit(self, node, method_name): method = getattr(self, 'visit_' + method_name, self.unknown_visit) return method(node) |
def dispatch_departure(self, node, method_name): | def dispatch_departure(self, node): node_name = node.__class__.__name__ | def dispatch_departure(self, node, method_name): method = getattr(self, 'depart_' + method_name, self.unknown_departure) return method(node) |
stylesheet = self.get_stylesheet_reference(os.getcwd()) | stylesheet = utils.get_stylesheet_reference(document.settings, os.path.join(os.getcwd(),'dummy')) | def __init__(self, document): |
print 'dummyUrllib2' | def urlopen(a): print 'dummyUrllib2' return StringIO.StringIO() | |
self.record_dependencies = docutils.utils.DependencyList() | if self.record_dependencies is None: self.record_dependencies = docutils.utils.DependencyList() | def __init__(self, *args, **kwargs): optparse.Values.__init__(self, *args, **kwargs) # Set up dependency list, in case it is needed. self.record_dependencies = docutils.utils.DependencyList() |
{'dest': 'record_dependencies', 'metavar': '<file>', 'validator': validate_dependency_file}), | {'metavar': '<file>', 'validator': validate_dependency_file, 'default': None}), | def process(self, opt, value, values, parser): """ Call the validator function on applicable settings and evaluate the 'overrides' option. Extends `optparse.Option.process`. """ result = optparse.Option.process(self, opt, value, values, parser) setting = self.dest if setting: if self.validator: value = getattr(values, ... |
'<frame x="160" y="72" width="600" height="432" leftmargin="36"' 'rightmargin="0">\n'%(self.slidenum, name)) | '<frame x="90" y="72" width="600" height="432" leftmargin="12"' 'rightmargin="0">\n'%(self.slidenum, name)) | def visit_section(self, node): if node.attributes.has_key('dupname'): name = node.attributes['dupname'] else: name = node.attributes['name'] self.slidenum += 1 self.w('<slide id="Slide%03d" title="%s">\n' '<frame x="160" y="72" width="600" height="432" leftmargin="36"' 'rightmargin="0">\n'%(self.slidenum, name)) |
if not self.suppress_para: self.w('<para>') | if not self.suppress_para: self.w('<para style="BodyText">') | def visit_paragraph(self, node): if not self.suppress_para: self.w('<para>') |
self.w('<pre>') | self.w('<prefmt style="Code">') | def visit_literal_block(self, node): self.w('<pre>') self.suppress_para = 1 |
self.w('</pre>\n') | self.w('</prefmt>\n') | def depart_literal_block(self, node): self.suppress_para = 0 self.w('</pre>\n') |
self.w('<tt>') | self.w('<div style="Code">') | def visit_literal(self, node): self.w('<tt>') |
self.w('</tt>') | self.w('</div>') | def depart_literal(self, node): self.w('</tt>') |
'cmdclass': {'install_data': smart_install_data}, | def do_setup(): kwargs = package_data.copy() extras = get_extras() if extras: kwargs['py_modules'] = extras if sys.hexversion >= 0x02030000: # Python 2.3 kwargs['classifiers'] = classifiers else: kwargs['cmdclass'] = {'build_py': dual_build_py} dist = setup(**kwargs) return dist | |
nodelist = self.transform_bibliographic(candidate) | nodelist = self.extract_bibliographic(candidate) | def transform(self): document = self.document index = document.first_child_not_matching_class( nodes.PreBibliographic) if index is None: return candidate = document[index] if isinstance(candidate, nodes.field_list): biblioindex = document.first_child_not_matching_class( nodes.Titular) nodelist = self.transform_bibliogr... |
ecasound_binary = os.getenv("ECASOUND","") | try: ecasound_binary = os.environ['ECASOUND'] except KeyError: ecasound_binary = '' | def initialize(I): |
r'''Find a single registered node that matches the given text. If none is found, but parsing is not yet complete, then suspend the calling tasklet, and try again when woken. If the `_no_suspend` attribute is true, it means that tasklets are being shut down, so instead of suspending, we raise LookupError. | r'''Find a single registered node that matches the given text. First, we suspend the calling tasklet to give all the other nodes a chance to get registered. Then we search them. If none is found, we suspend the calling tasklet, and try again when woken. If the `_no_suspend` attribute is true, it means that tasklets... | def find(self, typ, text): r'''Find a single registered node that matches the given text. If none is found, but parsing is not yet complete, then suspend the calling tasklet, and try again when woken. If the `_no_suspend` attribute is true, it means that tasklets are being shut down, so instead of suspending, we rais... |
if not found: | if found is None: | def find(self, typ, text): r'''Find a single registered node that matches the given text. If none is found, but parsing is not yet complete, then suspend the calling tasklet, and try again when woken. If the `_no_suspend` attribute is true, it means that tasklets are being shut down, so instead of suspending, we rais... |
if found: | if found is not None: | def find(self, typ, text): r'''Find a single registered node that matches the given text. If none is found, but parsing is not yet complete, then suspend the calling tasklet, and try again when woken. If the `_no_suspend` attribute is true, it means that tasklets are being shut down, so instead of suspending, we rais... |
ch = stackless.channel() self._suspended.add(ch) ch.receive() assert ch not in self._suspended del ch | def _suspend(self): r'''Suspend the running tasklet until awoken. ''' ch = stackless.channel() self._suspended.add(ch) ch.receive() assert ch not in self._suspended del ch | def find(self, typ, text): r'''Find a single registered node that matches the given text. If none is found, but parsing is not yet complete, then suspend the calling tasklet, and try again when woken. If the `_no_suspend` attribute is true, it means that tasklets are being shut down, so instead of suspending, we rais... |
hung = len(retry) while retry: retry.pop().send(None) if len(self._suspended) == hung: self._no_suspend = True | try: hung = len(retry) while retry: channel = retry.pop() channel.close() channel.send(None) if len(self._suspended) == hung: self._no_suspend = True finally: self._suspended.update(retry) | def finish_parsing(self): r'''Perform post-parsing cleanup. After this, the parse_block() method should not be invoked. All suspended tasklets are awoken, to give them a chance to resolve their node references. If none of them succeed, then it means we must have a circular reference, or that the remaining references... |
res = self.parse_residences(common) if res: self.parse_con(common, res, 'ph', Telephone, Has_fixed) self.parse_con(common, res, 'fax', Telephone, Has_fax) self.parse_con(common, res, 'com', Comment, Has_comment) | res = self.parse_ad(common, common.getvalue('ad')) self.parse_con(common, res, 'ph', Telephone, Has_fixed) self.parse_con(common, res, 'fax', Telephone, Has_fax) self.parse_con(common, res, 'com', Comment, Has_comment) | def _parse_data_block(self, block, defaults): r'''Parse a data block. This callable is invoked as a tasklet by parse_block(). ''' # Split the block into its parts. parts = parse.parts(block) for key in parts.iterkeys(): if key not in ('', '+', '-', '='): raise InputError('illegal delimiter', line=key) # Identify the "... |
self.parse_org_con(common, org) self.parse_org_extra(common, org) | self.parse_residences(common, org) | def _parse_data_block(self, block, defaults): r'''Parse a data block. This callable is invoked as a tasklet by parse_block(). ''' # Split the block into its parts. parts = parse.parts(block) for key in parts.iterkeys(): if key not in ('', '+', '-', '='): raise InputError('illegal delimiter', line=key) # Identify the "... |
self.parse_org_con(members[0], dept) | self.parse_residences(members[0], dept) | def _parse_data_block(self, block, defaults): r'''Parse a data block. This callable is invoked as a tasklet by parse_block(). ''' # Split the block into its parts. parts = parse.parts(block) for key in parts.iterkeys(): if key not in ('', '+', '-', '='): raise InputError('illegal delimiter', line=key) # Identify the "... |
fam = self.parse_family(common) | self.parse_family_con(common, fam) | def _parse_data_block(self, block, defaults): r'''Parse a data block. This callable is invoked as a tasklet by parse_block(). ''' # Split the block into its parts. parts = parse.parts(block) for key in parts.iterkeys(): if key not in ('', '+', '-', '='): raise InputError('illegal delimiter', line=key) # Identify the "... |
dept = None | if member.dept: self.parse_org_con(member, member.dept) | def _parse_data_block(self, block, defaults): r'''Parse a data block. This callable is invoked as a tasklet by parse_block(). ''' # Split the block into its parts. parts = parse.parts(block) for key in parts.iterkeys(): if key not in ('', '+', '-', '='): raise InputError('illegal delimiter', line=key) # Identify the "... |
dept = self.parse_dept(member, optional=True) if dept: Has_department(org, dept) self.parse_org_con(member, dept) per = self.parse_person(member, optional=bool(dept), principal=member.delim != '-') if org: if per: self.parse_works_at(member, per, dept or org) | if member.person: self.parse_works_at(member, member.person, member.dept or org) | def _parse_data_block(self, block, defaults): r'''Parse a data block. This callable is invoked as a tasklet by parse_block(). ''' # Split the block into its parts. parts = parse.parts(block) for key in parts.iterkeys(): if key not in ('', '+', '-', '='): raise InputError('illegal delimiter', line=key) # Identify the "... |
assert dept self.parse_org_extra(member, dept) | assert member.dept self.parse_org_extra(member, member.dept) | def _parse_data_block(self, block, defaults): r'''Parse a data block. This callable is invoked as a tasklet by parse_block(). ''' # Split the block into its parts. parts = parse.parts(block) for key in parts.iterkeys(): if key not in ('', '+', '-', '='): raise InputError('illegal delimiter', line=key) # Identify the "... |
assert per assert not dept Belongs_to(per, fam, | assert member.person assert not member.dept Belongs_to(member.person, fam, | def _parse_data_block(self, block, defaults): r'''Parse a data block. This callable is invoked as a tasklet by parse_block(). ''' # Split the block into its parts. parts = parse.parts(block) for key in parts.iterkeys(): if key not in ('', '+', '-', '='): raise InputError('illegal delimiter', line=key) # Identify the "... |
self.parse_contacts_work(member, per) self.parse_person_con(member, per, dept) | self.parse_contacts_work(member, member.person) self.parse_person_con(member, member.person, member.dept) | def _parse_data_block(self, block, defaults): r'''Parse a data block. This callable is invoked as a tasklet by parse_block(). ''' # Split the block into its parts. parts = parse.parts(block) for key in parts.iterkeys(): if key not in ('', '+', '-', '='): raise InputError('illegal delimiter', line=key) # Identify the "... |
self.parse_residences(part, org) | self.parse_homes(part, org) | def parse_org_con(self, part, org): r'''Parse contact details that may be associated with an organisation (company or department), skipping those that could pertain to a person, just in case this part also defines a person. If it doesn't, then the details we skip now will be parsed later in parse_org_extra(). ''' # Fi... |
res = self.parse_residences(sub, org) | self.parse_homes(sub, org) | def parse_org_con(self, part, org): r'''Parse contact details that may be associated with an organisation (company or department), skipping those that could pertain to a person, just in case this part also defines a person. If it doesn't, then the details we skip now will be parsed later in parse_org_extra(). ''' # Fi... |
def parse_family(self, part): r'''Parse a family and its associated contact details. ''' fam = self.register(Family()) res = self.parse_residences(part, fam) self.parse_con(part, res or fam, 'phh', Telephone, Has_fixed_home) self.parse_con(part, res or fam, 'faxh', Telephone, Has_fax_home) self.parse_con(part, res or f... | def parse_family_con(self, part, fam): r'''Parse a family's contact details. ''' self.parse_homes(part, fam) self.parse_con(part, fam, 'phh', Telephone, Has_fixed_home) self.parse_con(part, fam, 'faxh', Telephone, Has_fax_home) self.parse_con(part, fam, 'ph', Telephone, Has_fixed) self.parse_con(part, fam, 'fax', Telep... | def parse_family(self, part): r'''Parse a family and its associated contact details. ''' fam = self.register(Family()) res = self.parse_residences(part, fam) self.parse_con(part, res or fam, 'phh', Telephone, Has_fixed_home) self.parse_con(part, res or fam, 'faxh', Telephone, Has_fax_home) self.parse_con(part, res or f... |
res = self.parse_residences(sub, fam) if res: self.parse_con(part, res, 'ph', Telephone, Has_fixed) self.parse_con(part, res, 'fax', Telephone, Has_fax) | self.parse_homes(sub, fam) | def parse_family(self, part): r'''Parse a family and its associated contact details. ''' fam = self.register(Family()) res = self.parse_residences(part, fam) self.parse_con(part, res or fam, 'phh', Telephone, Has_fixed_home) self.parse_con(part, res or fam, 'faxh', Telephone, Has_fax_home) self.parse_con(part, res or f... |
res = None | def parse_person_con(self, part, per, org=None): r'''Parse a person's contact details and attach them to a given Person node. @param org: if not None, then 'part' also defines an Organisation, so skip those contact details which pertain to the organisation (so we don't parse them twice) ''' # First, parse residences th... | |
res = self.parse_residences(part, per) | self.parse_homes(part, per) | def parse_person_con(self, part, per, org=None): r'''Parse a person's contact details and attach them to a given Person node. @param org: if not None, then 'part' also defines an Organisation, so skip those contact details which pertain to the organisation (so we don't parse them twice) ''' # First, parse residences th... |
self.parse_con(part, res or per, 'phh', Telephone, Has_fixed_home) self.parse_con(part, res or per, 'faxh', Telephone, Has_fax_home) | self.parse_con(part, per, 'phh', Telephone, Has_fixed_home) self.parse_con(part, per, 'faxh', Telephone, Has_fax_home) | def parse_person_con(self, part, per, org=None): r'''Parse a person's contact details and attach them to a given Person node. @param org: if not None, then 'part' also defines an Organisation, so skip those contact details which pertain to the organisation (so we don't parse them twice) ''' # First, parse residences th... |
self.parse_con(part, res or per, 'ph', Telephone, Has_fixed) self.parse_con(part, res or per, 'fax', Telephone, Has_fax) | self.parse_con(part, per, 'ph', Telephone, Has_fixed) self.parse_con(part, per, 'fax', Telephone, Has_fax) | def parse_person_con(self, part, per, org=None): r'''Parse a person's contact details and attach them to a given Person node. @param org: if not None, then 'part' also defines an Organisation, so skip those contact details which pertain to the organisation (so we don't parse them twice) ''' # First, parse residences th... |
self.parse_con(sub, res or per, 'phh', Telephone, Has_fixed_home) self.parse_con(sub, res or per, 'faxh', Telephone, Has_fax_home) | self.parse_con(sub, per, 'phh', Telephone, Has_fixed_home) self.parse_con(sub, per, 'faxh', Telephone, Has_fax_home) | def parse_person_con(self, part, per, org=None): r'''Parse a person's contact details and attach them to a given Person node. @param org: if not None, then 'part' also defines an Organisation, so skip those contact details which pertain to the organisation (so we don't parse them twice) ''' # First, parse residences th... |
res = self.parse_residences(sub, per) | self.parse_homes(sub, per) | def parse_person_con(self, part, per, org=None): r'''Parse a person's contact details and attach them to a given Person node. @param org: if not None, then 'part' also defines an Organisation, so skip those contact details which pertain to the organisation (so we don't parse them twice) ''' # First, parse residences th... |
self.parse_con(sub, res or per, 'ph', Telephone, Has_fixed_home) self.parse_con(sub, res or per, 'fax', Telephone, Has_fax_home) | self.parse_con(sub, per, 'ph', Telephone, Has_fixed_home) self.parse_con(sub, per, 'fax', Telephone, Has_fax_home) | def parse_person_con(self, part, per, org=None): r'''Parse a person's contact details and attach them to a given Person node. @param org: if not None, then 'part' also defines an Organisation, so skip those contact details which pertain to the organisation (so we don't parse them twice) ''' # First, parse residences th... |
r residences = set() | r | def parse_residences(self, part, who=None): r'''Parse 'ad' and 'home' lines for a person, family or organisation, which define to one or more residences and contact details for that person/organisation. ''' residences = set() for value, sub in part.mget('ad', []): res, comment = Residence.parse(value, world= self.worl... |
res, comment = Residence.parse(value, world= self.world, place= part.place, default_place=part.defaults.place) assert comment is None res = self.register(res) residences.add(res) | res = self.parse_ad(part, value, sub) if who: Resides_at(who, res, timestamp=(sub or part).updated) for insub in (s for v, s in part.mget('in', []) if s): for value, sub in insub.mget('ad', []): res = self.parse_ad(part, value, sub) if who: Resides_at(who, res, timestamp=(sub or part).updated) def parse_ad(self, part,... | def parse_residences(self, part, who=None): r'''Parse 'ad' and 'home' lines for a person, family or organisation, which define to one or more residences and contact details for that person/organisation. ''' residences = set() for value, sub in part.mget('ad', []): res, comment = Residence.parse(value, world= self.worl... |
self.parse_con(sub, res, 'ph', Telephone, Has_fixed) self.parse_con(sub, res, 'fax', Telephone, Has_fax) self.parse_con(sub, res, 'com', Comment, Has_comment) if who: Resides_at(who, res, timestamp=(sub or part).updated) if who: for value, sub in part.mget('home', []): try: res = self.find(Residence, value) except Look... | r = Resides_at(who, res, timestamp=(sub or part).updated) if sub: self.parse_con(sub, r, 'ph', Telephone, Has_fixed) self.parse_con(sub, r, 'fax', Telephone, Has_fax) self.parse_con(sub, r, 'com', Comment, Has_comment) | def parse_residences(self, part, who=None): r'''Parse 'ad' and 'home' lines for a person, family or organisation, which define to one or more residences and contact details for that person/organisation. ''' residences = set() for value, sub in part.mget('ad', []): res, comment = Residence.parse(value, world= self.worl... |
r'''Since we're overriding the builtin L{str} class, we can't mess | r'''Since we're overriding the builtin L{unicode} class, we can't mess | def new(class_, text, loc=None): r'''Since we're overriding the builtin L{str} class, we can't mess with the constructor, so we use this class method to construct itext instances. @param text: any object that supports unicode(text) @param loc: either None or any object that supports integer addition and subtraction: lo... |
str.__init__(self, text) | unicode.__init__(self, text) | def __init__(self, text=u''): str.__init__(self, text) self.__loc = [] |
>>> set(n1.links(is_link(A))) == set([a12, a31]) True >>> set(n1.links(~is_link(A))) == set([c12, c21]) True >>> set(n1.links(is_link(A) & outgoing)) == set([a12]) True >>> set(n1.links(is_link(B))) == set([b21, b13]) True >>> set(n1.links(is_link(C))) == set([c12, c21]) True >>> set(n1.links(is_link(C) | is_link(B))) ... | >>> set(n1.links(is_link_only(A))) == set([a12, a31]) True >>> set(n1.links(~is_link_only(A))) == set([b13, b21, c12, c21]) True >>> set(n1.links(is_link_only(A) & outgoing)) == set([a12]) True >>> set(n1.links(is_link_only(B))) == set([b21, b13]) True >>> set(n1.links(is_link_only(C))) == set([c12, c21]) True >>> set(... | def is_link_only(typ): r'''Return a predicate that matches links of the given type but not subtypes thereof. >>> class A(Link): pass >>> class B(A): pass >>> class C(Link): pass >>> n1 = Node() >>> n2 = Node() >>> n3 = Node() >>> a12 = A(n1, n2) >>> a23 = A(n2, n3) >>> a31 = A(n3, n1) >>> b13 = B(n1, n3) >>> b32 = B(n... |
raise InputError('no country or area matching "%s"' % name, char=name) | raise LookupError('no country or area matching "%s"' % name) | def lookup_place(self, name): country = self.lookup_country(name, None) if country: return Place(country) area = self.lookup_area(name, None) if area: return Place(area) raise InputError('no country or area matching "%s"' % name, char=name) |
example += '<Language Name="Example Language" Author="arnetheduck" Version=' + version + ' Revision="1" RightToLeft="0">\n' | example += '<Language Name="Example Language" Native="English" Code="en" Author="arnetheduck" Version=' + version + ' Revision="1" RightToLeft="0">\n' | def makename(oldname): name = ""; nextBig = True; for x in oldname: if x == '_': nextBig = True; else: if nextBig: name += x.upper(); nextBig = False; else: name += x.lower(); return name; |
def __init__(self,redland_model,resource,node): self.model=redland_model | def __init__(self,resource,node): | def __init__(self,redland_model,resource,node): self.model=redland_model self.name=resource.split('#')[1] self.resource=resource if (type(node)==RDF.Node): self.rdf_node=node elif (type(node)==Node): self.xml_node=node |
def __init__(self,redland_model,resource,node): | obj_properties=[] dt_properties=[] mandatory_properties=[] def __init__(self,resource,node): | def __init__(self,redland_model,resource,node): rdf_type='http://www.w3.org/2002/07/owl#Class' OWL_Resource.__init__(self,resource,node) |
obj_properties=[] dt_properties=[] | def __init__(self,redland_model,resource,node): rdf_type='http://www.w3.org/2002/07/owl#Class' OWL_Resource.__init__(self,resource,node) | |
def __search_class_for_data(self,starting_class,textual_data,path=[],exclude_blacklist=False): | def __search_class_for_data(self,starting_class,textual_data,path=[],use_blacklist=True): | def __search_class_for_data(self,starting_class,textual_data,path=[],exclude_blacklist=False): """ Resolve the case in which an attribute is linked to an ObjectProperty. Search a class with a DatatypeProperty following the ObjectProperties starting_class(OWL_Class): starting point for the search textual_data (string): ... |
exclude_blacklist (boolean): if True exclude a set of DatatypeProperties from the search | use_blacklist (boolean): if True exclude a set of DatatypeProperties from the search | def __search_class_for_data(self,starting_class,textual_data,path=[],exclude_blacklist=False): """ Resolve the case in which an attribute is linked to an ObjectProperty. Search a class with a DatatypeProperty following the ObjectProperties starting_class(OWL_Class): starting point for the search textual_data (string): ... |
if (not exclude_blacklist): if (p in self.__datatypes_blacklisted): | if use_blacklist: if (not (p in self.__datatypes_blacklisted)): | def __search_class_for_data(self,starting_class,textual_data,path=[],exclude_blacklist=False): """ Resolve the case in which an attribute is linked to an ObjectProperty. Search a class with a DatatypeProperty following the ObjectProperties starting_class(OWL_Class): starting point for the search textual_data (string): ... |
if name == IncludeType: include=attrs['schemaLocation'] self.includes.append(include) | def startElement(self, name, attrs): #dbgprint(1, 'before schema name: %s SchemaType: %s' % (name, SchemaType,)) if name == IncludeType: include=attrs['schemaLocation'] self.includes.append(include) | |
from xml.dom.ext.reader import Sax2 from xml import xpath | included_root_list=[] | def parseAndGenerate(outfileName, subclassFilename, prefix, \ xschemaFileName, behaviorFilename, superModule='???'): includes=[] from xml.dom.ext.reader import Sax2 from xml import xpath doc=None if '://' in xschemaFileName: doc = Sax2.FromXmlUrl(xschemaFileName).documentElement else: doc = Sax2.FromXmlFile(xschemaFile... |
print outFile parseAndGenerate(outFile,None,None,i,None,None) | def parseAndGenerate(outfileName, subclassFilename, prefix, \ xschemaFileName, behaviorFilename, superModule='???'): includes=[] from xml.dom.ext.reader import Sax2 from xml import xpath doc=None if '://' in xschemaFileName: doc = Sax2.FromXmlUrl(xschemaFileName).documentElement else: doc = Sax2.FromXmlFile(xschemaFile... | |
nameSpace = 'xs:' | nameSpace = 'xsd:' | def main(): global Force, GenerateProperties, SubclassSuffix, RootElement, \ ValidatorBodiesBasePath args = sys.argv[1:] options, args = getopt.getopt(args, 'fyo:s:p:a:b:m', ['subclass-suffix=', 'root-element=', 'super=', 'validator-bodies=', ]) prefix = '' outFilename = None subclassFilename = None behaviorFilename = ... |
print 'succ rate :', self.succRate, ', succ perf :', self.succPerf | def __calculSuccessRates(self): """ Update succRate & succPerf values, according to the current optima list and problem instance """ total = self.runsNb success = 0 successIndex = [] for point in self.optima: if self.__success(point): success += 1 successIndex.append(point.index) self.succRate = float(success) / float(... | |
try: | def __plot_3(self): """ Plot the graph of optimas' values, to finally have one Point for each Test, we present 3 selections : - best optimum - worst optimum - median optimum value""" fileName = os.path.join(self.__dir, 'graph_optima.ps') r.postscript(fileName, paper='letter') # make best optima list (minima) olist = [(... | |
r.points(wlist, bg ='white', pch = 21) | r.points(wlist, bg ='white', pch = 21, lty='dashed') | def __plot_3(self): """ Plot the graph of optimas' values, to finally have one Point for each Test, we present 3 selections : - best optimum - worst optimum - median optimum value""" fileName = os.path.join(self.__dir, 'graph_optima.ps') r.postscript(fileName, paper='letter') # make best optima list (minima) olist = [(... |
r.points(mlist, bg ='white', pch = 21) r.grid(nx=10, ny=40) | r.points(mlist, bg ='white', pch = 21, lty='dotted') r.grid(nx=10, ny=40) | def __plot_3(self): """ Plot the graph of optimas' values, to finally have one Point for each Test, we present 3 selections : - best optimum - worst optimum - median optimum value""" fileName = os.path.join(self.__dir, 'graph_optima.ps') r.postscript(fileName, paper='letter') # make best optima list (minima) olist = [(... |
except: if self.__LOG: self.__LOG = 0 print 'Cannot use logarithmic scale 1' r.grid(nx=10, ny=40) r.plot(wlist, type='n', main='Worsts optima evolution', xlab='Test index', ylab='Optima value') r.lines(wlist) r.points(wlist, bg ='white', pch = 21) r.grid(nx=10, ny=40) r.plot(mlist, type='n', main='Median optima evolut... | def __plot_3(self): """ Plot the graph of optimas' values, to finally have one Point for each Test, we present 3 selections : - best optimum - worst optimum - median optimum value""" fileName = os.path.join(self.__dir, 'graph_optima.ps') r.postscript(fileName, paper='letter') # make best optima list (minima) olist = [(... | |
xfile = os.path.join(self.__path, filename) | xfile = os.path.join(self.__dir, filename) | def __copyToDisk(self, rfd, filename="xml"): """ Copy the file opened with rfd to a new file on disk, is used to copy XML output on disk. """ filename += '.xml' xfile = os.path.join(self.__path, filename) try: wfd = open(xfile, 'w') except: self.log('ERROR : cannot create file, maybe directory does not exists... [Test.... |
for s in os.listdir(self.__path): | for s in os.listdir(self.__dir): | def __archiveXml(self): """ Create a compressed tar archive of XML files. """ try: import tarfile path = 'xml.tar.gz' tf = tarfile.open(name=path, mode='w:gz') for s in os.listdir(self.__path): if s[-4:] == '.xml': f = os.path.join(self.__path, s) tf.add(f) os.remove(f) tf.close() except: self.__fatal('cannot create XM... |
f = os.path.join(self.__path, s) | f = os.path.join(self.__dir, s) | def __archiveXml(self): """ Create a compressed tar archive of XML files. """ try: import tarfile path = 'xml.tar.gz' tf = tarfile.open(name=path, mode='w:gz') for s in os.listdir(self.__path): if s[-4:] == '.xml': f = os.path.join(self.__path, s) tf.add(f) os.remove(f) tf.close() except: self.__fatal('cannot create XM... |
print 'path', path | def archiveXml(self): """ Create a compressed tar archive of XML files. """ try: import tarfile path = os.path.join(self.__path, 'xml.tar.gz') tf = tarfile.open(name=path, mode='w:gz') print 'path', path for s in os.listdir(self.__path): if s[-4:] == '.xml': f = os.path.join(self.__path, s) tf.add(f) os.remove(f) tf.cl... | |
DateTimeBehavior.transformFromNative(obj, False) | return DateTimeBehavior.transformFromNative(obj, False) | def transformFromNative(obj): DateTimeBehavior.transformFromNative(obj, False) |
error("error: unknown state: '%s' reached in %s" % (state, line)) | error("error: unknown state: '%s' reached in %s" % (state, s)) | def error(msg): if strict: raise ParseError(msg) else: raise ParseError(msg) #logger.error(msg) |
if not (rule._freq == dateutil.rrule.YEARLY and len(rule._bymonth) == 1 and rule._bymonth[0] == rule._dtstart.month): | if (rule._byweekday is not None or len(rrule._bynweekday or ()) > 0 or not (rule._freq == dateutil.rrule.YEARLY and len(rule._bymonth) == 1 and rule._bymonth[0] == rule._dtstart.month)): | def setrruleset(self, rruleset): dtstart = self.dtstart.value isDate = datetime.date == type(dtstart) if isDate: dtstart = datetime.datetime(dtstart.year,dtstart.month, dtstart.day) untilSerialize = dateToString else: # make sure to convert time zones to UTC untilSerialize = lambda x: dateTimeToString(x, True) |
del self.contents[named] | del self.contents[obj.name.lower()] | def remove(self, obj): """Remove obj from contents.""" named = self.contents.get(obj.name.lower()) if named: try: named.remove(obj) if len(named) == 0: del self.contents[named] except ValueError: pass; |
for encoding in 'utf-8', 'utf-16-LE', 'utf-16-BE': | for encoding in 'utf-8', 'utf-16-LE', 'utf-16-BE', 'iso-8859-1': | def getLogicalLines(fp, allowQP=True, findBegin=False): """Iterate through a stream, yielding one logical line at a time. Because many applications still use vCard 2.1, we have to deal with the quoted-printable encoding for long lines, as well as the vCard 3.0 and vCalendar line folding technique, a whitespace charact... |
return Duration.transformToNative(obj) | try: return Duration.transformToNative(obj) except ParseError: logger.warn("TRIGGER not recognized as DURATION, trying \ DATE-TIME, because iCal sometimes exports \ DATE-TIMEs without setting VALUE=DATE-TIME") try: obj.isNative = False dt = DateTimeBehavior.transformToNative(obj) return dt except: msg = "TRIGGER with n... | def transformToNative(obj): """Turn obj.value into a timedelta or datetime.""" value = getattr(obj, 'value_param', 'DURATION').upper() if hasattr(obj, 'value_param'): del obj.value_param if obj.value == '': obj.isNative = True return obj elif value == 'DURATION': return Duration.transformToNative(obj) elif value == 'D... |
return DateTimeBehavior.transformFromNative(obj) | return DateTimeBehavior.transformFromNative(obj, convertToUTC=True) | def transformFromNative(obj): if type(obj.value) == datetime.datetime: obj.value_param = 'DATE-TIME' return DateTimeBehavior.transformFromNative(obj) elif type(obj.value) == datetime.timedelta: return Duration.transformFromNative(obj) else: raise NativeError("Native TRIGGER values must be timedelta or datetime") |
When creating rrule's programmatically it should be kept in mind that count doesn't necessarily mean what rfc2445 says. | def prettyPrint(self, level, tabwidth): pre = ' ' * level * tabwidth print pre, self.name print pre, "TZID:", self.tzid[0] print | |
[datetime.datetime(2005, 1, 19, 9, 0), datetime.datetime(2005, 1, 20, 9, 0)] | [datetime.datetime(2005, 3, 18, 0, 0), datetime.datetime(2005, 3, 29, 0, 0)] | def prettyPrint(self, level, tabwidth): pre = ' ' * level * tabwidth print pre, self.name print pre, "TZID:", self.tzid[0] print |
if rruleset._rrule[-1][0] != dtstart: rruleset.rdate(dtstart) | if not isinstance(dtstart, datetime.datetime): adddtstart = datetime.datetime.fromordinal(dtstart.toordinal()) else: adddtstart = dtstart if rruleset._rrule[-1][0] != adddtstart: rruleset.rdate(adddtstart) | def getrruleset(self, addRDate = False): """Get an rruleset created from self. If addRDate is True, add an RDATE for dtstart if it's not included in an RRULE, and count is decremented if it exists. Note that for rules which don't match DTSTART, DTSTART may not appear in list(rruleset), although it should. By default... |
return "<Address: %s>" % self.__str__().replace('\n', '\\n') | return "<Address: %s>" % repr(str(self))[1:-1] | def __repr__(self): return "<Address: %s>" % self.__str__().replace('\n', '\\n') |
if until is not None and until.tzinfo != dtstart.tzinfo: | if until is not None and \ isinstance(dtstart, datetime.datetime) and \ (until.tzinfo != dtstart.tzinfo): | def getrruleset(self, addRDate = False): """Get an rruleset created from self. If addRDate is True, add an RDATE for dtstart if it's not included in an RRULE, and count is decremented if it exists. Note that for rules which don't match DTSTART, DTSTART may not appear in list(rruleset), although it should. By default... |
Return the last date not matching test, or None if all tests matched. """ success = None for dt in iterDates: if not test(dt): success = dt else: if success is not None: return success return success def generateDates(year, month=None, day=None): """Iterate over possible dates with unspecified values.""" months = rang... | """ | def settzinfo(self, tzinfo, start=2000, end=2030): """Create appropriate objects in self to represent tzinfo. Assumptions: - DST <-> Standard transitions occur on the hour - never within a month of one another - twice or fewer times a year - never in the month of December - DST always moves offset exactly one hour lat... |
def getTransitionOccurrence(year, month, dayofweek, n, hour): weekday = dateutil.rrule.weekday(dayofweek, n) if hour is None: return datetime.datetime(year, 1, 1) rule = dateutil.rrule.rrule(dateutil.rrule.YEARLY, bymonth = month, byweekday = weekday, dtstart = datetime.datetime(year, 1, 1, hour)) return rule[0] | def getTransitionOccurrence(year, month, dayofweek, n, hour): weekday = dateutil.rrule.weekday(dayofweek, n) if hour is None: # all year offset, with no rule return datetime.datetime(year, 1, 1) rule = dateutil.rrule.rrule(dateutil.rrule.YEARLY, bymonth = month, byweekday = weekday, dtstart = datetime.datetime(year, 1,... | |
test = tests[transitionTo] monthDt = firstTransition(generateDates(year), test) if monthDt is None: | if transition == newyear: | def getTransitionOccurrence(year, month, dayofweek, n, hour): weekday = dateutil.rrule.weekday(dayofweek, n) if hour is None: # all year offset, with no rule return datetime.datetime(year, 1, 1) rule = dateutil.rrule.rrule(dateutil.rrule.YEARLY, bymonth = month, byweekday = weekday, dtstart = datetime.datetime(year, 1,... |
yearStart = datetime.datetime(year, 1, 1) | def getTransitionOccurrence(year, month, dayofweek, n, hour): weekday = dateutil.rrule.weekday(dayofweek, n) if hour is None: # all year offset, with no rule return datetime.datetime(year, 1, 1) rule = dateutil.rrule.rrule(dateutil.rrule.YEARLY, bymonth = month, byweekday = weekday, dtstart = datetime.datetime(year, 1,... | |
'start' : yearStart, | 'start' : newyear, | def getTransitionOccurrence(year, month, dayofweek, n, hour): weekday = dateutil.rrule.weekday(dayofweek, n) if hour is None: # all year offset, with no rule return datetime.datetime(year, 1, 1) rule = dateutil.rrule.rrule(dateutil.rrule.YEARLY, bymonth = month, byweekday = weekday, dtstart = datetime.datetime(year, 1,... |
'name' : tzinfo.tzname(yearStart), 'offset' : tzinfo.utcoffset(yearStart), 'offsetfrom' : tzinfo.utcoffset(yearStart)} | 'name' : tzinfo.tzname(newyear), 'offset' : tzinfo.utcoffset(newyear), 'offsetfrom' : tzinfo.utcoffset(newyear)} | def getTransitionOccurrence(year, month, dayofweek, n, hour): weekday = dateutil.rrule.weekday(dayofweek, n) if hour is None: # all year offset, with no rule return datetime.datetime(year, 1, 1) rule = dateutil.rrule.rrule(dateutil.rrule.YEARLY, bymonth = month, byweekday = weekday, dtstart = datetime.datetime(year, 1,... |
tzinfo.utcoffset(yearStart)): | tzinfo.utcoffset(newyear)): | def getTransitionOccurrence(year, month, dayofweek, n, hour): weekday = dateutil.rrule.weekday(dayofweek, n) if hour is None: # all year offset, with no rule return datetime.datetime(year, 1, 1) rule = dateutil.rrule.rrule(dateutil.rrule.YEARLY, bymonth = month, byweekday = weekday, dtstart = datetime.datetime(year, 1,... |
continue elif monthDt.month == 12: | elif transition is None: | def getTransitionOccurrence(year, month, dayofweek, n, hour): weekday = dateutil.rrule.weekday(dayofweek, n) if hour is None: # all year offset, with no rule return datetime.datetime(year, 1, 1) rule = dateutil.rrule.rrule(dateutil.rrule.YEARLY, bymonth = month, byweekday = weekday, dtstart = datetime.datetime(year, 1,... |
continue | def getTransitionOccurrence(year, month, dayofweek, n, hour): weekday = dateutil.rrule.weekday(dayofweek, n) if hour is None: # all year offset, with no rule return datetime.datetime(year, 1, 1) rule = dateutil.rrule.rrule(dateutil.rrule.YEARLY, bymonth = month, byweekday = weekday, dtstart = datetime.datetime(year, 1,... | |
month = monthDt.month day = firstTransition(generateDates(year, month), test).day uncorrected = firstTransition(generateDates(year, month, day), test) if transitionTo == 'standard': corrected = uncorrected + datetime.timedelta(hours=2) else: corrected = uncorrected + datetime.timedelta(hours=1) rule = {... | old_offset = tzinfo.utcoffset(transition - twoHours) rule = {'end' : None, 'start' : transition, 'month' : transition.month, 'weekday' : transition.weekday(), 'hour' : transition.hour, 'name' : tzinfo.tzname(transition), 'plus' : (transition.day - 1)/ 7 + 1, 'minus' : fromLastWeek(transition), 'offse... | def getTransitionOccurrence(year, month, dayofweek, n, hour): weekday = dateutil.rrule.weekday(dayofweek, n) if hour is None: # all year offset, with no rule return datetime.datetime(year, 1, 1) rule = dateutil.rrule.rrule(dateutil.rrule.YEARLY, bymonth = month, byweekday = weekday, dtstart = datetime.datetime(year, 1,... |
oldrule['end'] = year - 1 completed[transitionTo].append(oldrule) working[transitionTo] = rule | plusMatch = rule['plus'] == oldrule['plus'] minusMatch = rule['minus'] == oldrule['minus'] truth = plusMatch or minusMatch for key in 'month', 'weekday', 'hour', 'offset': truth = truth and rule[key] == oldrule[key] if truth: if not plusMatch: oldrule['plus'] = None if not minusMatch: oldrule['minus'] = None else: ... | def getTransitionOccurrence(year, month, dayofweek, n, hour): weekday = dateutil.rrule.weekday(dayofweek, n) if hour is None: # all year offset, with no rule return datetime.datetime(year, 1, 1) rule = dateutil.rrule.rrule(dateutil.rrule.YEARLY, bymonth = month, byweekday = weekday, dtstart = datetime.datetime(year, 1,... |
endDate = getTransitionOccurrence(rule['end'], rule['month'], rule['weekday'], num, rule['hour']) | if rule['hour'] is None: endDate = datetime.datetime(rule['end'], 1, 1) else: weekday = dateutil.rrule.weekday(rule['weekday'], num) du_rule = dateutil.rrule.rrule(dateutil.rrule.YEARLY, bymonth = rule['month'],byweekday = weekday, dtstart = datetime.datetime( rule['end'], 1, 1, rule['hour']) ) endDate = du_rule[0] | def getTransitionOccurrence(year, month, dayofweek, n, hour): weekday = dateutil.rrule.weekday(dayofweek, n) if hour is None: # all year offset, with no rule return datetime.datetime(year, 1, 1) rule = dateutil.rrule.rrule(dateutil.rrule.YEARLY, bymonth = month, byweekday = weekday, dtstart = datetime.datetime(year, 1,... |
if tzinfo is None or tzinfo == utc: | if tzinfo is None or tzinfo_eq(tzinfo, utc): | def pickTzid(tzinfo): """ Given a tzinfo class, use known APIs to determine TZID, or use tzname. """ if tzinfo is None or tzinfo == utc: #If tzinfo is UTC, we don't need a TZID return None # try PyICU's tzid key if hasattr(tzinfo, 'tzid'): return tzinfo.tzid |
if dateTime.tzinfo == utc: utcString = "Z" | if tzinfo_eq(dateTime.tzinfo, utc): utcString = "Z" | def dateTimeToString(dateTime, preserveTZ=True): """Convert to UTC if tzinfo is set, unless preserveTZ. Output string.""" if dateTime.tzinfo and not preserveTZ: dateTime = dateTime.astimezone(utc) if dateTime.tzinfo == utc: utcString = "Z" else: utcString = "" year = numToDigits( dateTime.year, 4 ) month = numToDig... |
return self.params[name[:-6].upper().replace('_', '-')][0] | return self.params[toVName(name, 6, True)][0] | def __getattr__(self, name): """Make params accessible via self.foo_param or self.foo_paramlist. |
return self.params[name[:-10].upper().replace('_', '-')] | return self.params[toVName(name, 10, True)] | def __getattr__(self, name): """Make params accessible via self.foo_param or self.foo_paramlist. |
self.params[name[:-6].upper().replace('_', '-')] = value else: self.params[name[:-6].upper().replace('_', '-')] = [value] | self.params[toVName(name, 6, True)] = value else: self.params[toVName(name, 6, True)] = [value] | def __setattr__(self, name, value): """Make params accessible via self.foo_param or self.foo_paramlist. |
self.params[name[:-10].upper().replace('_', '-')] = value | self.params[toVName(name, 10, True)] = value | def __setattr__(self, name, value): """Make params accessible via self.foo_param or self.foo_paramlist. |
del self.params[name[:-6].upper().replace('_', '-')] | del self.params[toVName(name, 6, True)] | def __delattr__(self, name): try: if name.endswith('_param'): del self.params[name[:-6].upper().replace('_', '-')] elif name.endswith('_paramlist'): del self.params[name[:-10].upper().replace('_', '-')] else: object.__delattr__(self, name) except KeyError: raise exceptions.AttributeError, name |
del self.params[name[:-10].upper().replace('_', '-')] | del self.params[toVName(name, 10, True)] | def __delattr__(self, name): try: if name.endswith('_param'): del self.params[name[:-6].upper().replace('_', '-')] elif name.endswith('_paramlist'): del self.params[name[:-10].upper().replace('_', '-')] else: object.__delattr__(self, name) except KeyError: raise exceptions.AttributeError, name |
return self.contents[name[:-5].replace('_', '-')] else: return self.contents[name.replace('_', '-')][0] | return self.contents[toVName(name, 5)] else: return self.contents[toVName(name)][0] | def __getattr__(self, name): """For convenience, make self.contents directly accessible. Underscores, legal in python variable names, are converted to dashes, which are legal in IANA tokens. """ try: if name.endswith('_list'): return self.contents[name[:-5].replace('_', '-')] else: return self.contents[name.replace('... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.