rem
stringlengths
0
322k
add
stringlengths
0
2.05M
context
stringlengths
8
228k
print >> outfile, utils.indent('"""\n%s\n"""' % doc, 2)
print >> outfile, utils.indent('"""%s\n"""' % doc, 2)
print >> outfile, ' def %s(%s):' % (m.getName(), paramstr[1:])
parent_schema=["getattr(%s, 'schema', Schema(()))" % p.getCleanName() \ for p in element.getGenParents()]
parent_schema = ["getattr(%s, 'schema', Schema(()))" % p.getCleanName() for p in element.getGenParents() if not p.hasStereoType(self.python_stereotype, umlprofile=self.uml_profile)]
def generateArchetypesClass(self, element, **kw): """this is the all singing all dancing core generator logic for a full featured Archetypes class """ log.info("%sGenerating class '%s'.", ' '*self.infoind, element.getName())
if utils.isTGVTrue(element.getTaggedValue('inherit_allowed_types', True)) and element.getGenParents():
if utils.isTGVTrue(element.getTaggedValue('inherit_allowed_types', \ True)) and element.getGenParents():
def generateArchetypesClass(self, element, **kw): """this is the all singing all dancing core generator logic for a full featured Archetypes class """ log.info("%sGenerating class '%s'.", ' '*self.infoind, element.getName())
print >> outfile, CLASS_ALLOWED_CONTENT_TYPES % (repr(aggregatedClasses),parentAggregates) parentAggregatedInterfaces='' if utils.isTGVTrue(element.getTaggedValue('inherit_allowed_types', True)) and element.getGenParents(): parentAggregatedInterfaces = '+ ' + ' + '.join(tuple(['getattr('+p.getCleanName()+",'allowed_i...
print >> outfile, CLASS_ALLOWED_CONTENT_TYPES % \ (repr(aggregatedClasses),parentAggregates) parentAggregatedInterfaces = '' if utils.isTGVTrue(element.getTaggedValue('inherit_allowed_types', \ True)) and element.getGenParents(): pattern = "getattr(%s, 'allowed_interfaces', [])" extras = ' + '.join([pattern % p.getCl...
def generateArchetypesClass(self, element, **kw): """this is the all singing all dancing core generator logic for a full featured Archetypes class """ log.info("%sGenerating class '%s'.", ' '*self.infoind, element.getName())
print >>outfile, CLASS_RENAME_AFTER_CREATION % (utils.isTGVTrue(rename_after_creation) and 'True' or 'False')
print >> outfile, CLASS_RENAME_AFTER_CREATION % \ (utils.isTGVTrue(rename_after_creation) and 'True' or 'False')
def generateArchetypesClass(self, element, **kw): """this is the all singing all dancing core generator logic for a full featured Archetypes class """ log.info("%sGenerating class '%s'.", ' '*self.infoind, element.getName())
tool_instance_name=element.getTaggedValue('tool_instance_name') or 'portal_%s' % element.getName().lower() print >> outfile,TEMPL_CONSTR_TOOL % (baseclass,tool_instance_name) self.generateProtectedSection(outfile,element,'constructor-footer',2)
tool_instance_name = element.getTaggedValue('tool_instance_name') \ or 'portal_%s' % element.getName().lower() print >> outfile, TEMPL_CONSTR_TOOL % (baseclass,tool_instance_name) self.generateProtectedSection(outfile, element, 'constructor-footer', 2)
def generateArchetypesClass(self, element, **kw): """this is the all singing all dancing core generator logic for a full featured Archetypes class """ log.info("%sGenerating class '%s'.", ' '*self.infoind, element.getName())
if element.hasStereoType(self.vocabulary_item_stereotype, umlprofile=self.uml_profile) and \ not element.isAbstract ():
if element.hasStereoType(self.vocabulary_item_stereotype, umlprofile=self.uml_profile) and not element.isAbstract():
def generateArchetypesClass(self, element, **kw): """this is the all singing all dancing core generator logic for a full featured Archetypes class """ log.info("%sGenerating class '%s'.", ' '*self.infoind, element.getName())
print >> outfile, utils.indent('"""\n%s\n"""' % doc, 1)
print >> outfile, utils.indent('"""%s\n"""' % doc, 1)
def generateZope2Interface(self, element, **kw): outfile = StringIO() log.info("%sGenerating zope2 interface '%s'.", ' '*self.infoind, element.getName())
wrt('\n\n
wrt('\n
def generateZope2Interface(self, element, **kw): outfile = StringIO() log.info("%sGenerating zope2 interface '%s'.", ' '*self.infoind, element.getName())
field_spec.get('rawType', None), field_spec.get('array_field', None),
field_spec['rawType'], field_spec['array_field'],
def getFieldsFormatted(self, field_specs): """Return the formatted field definitions for the schema from field_specs. """ res = '' for field_spec in field_specs: log.debug("field_spec is %r.", field_spec) try: res += self.getFieldFormatted(field_spec['name'], field_spec['fieldtype'], field_spec['map'], field_spec['doc'...
def hasStereoType(self,s): return 0
def hasStereoType(self, s, umlprofile=None): return True
def hasStereoType(self,s): return 0
workflowTool._setObject('<dtml-var "generator.cleanName(sm.getName())">', workflow)
if '<dtml-var "generator.cleanName(sm.getName())">' in workflowTool.listWorkflows(): print >> out, '<dtml-var "generator.cleanName(sm.getName())"> already in workflows.' else: workflowTool._setObject('<dtml-var "generator.cleanName(sm.getName())">', workflow)
def installWorkflows(self, package, out): """Install the custom workflows for this product.""" productname = '<dtml-var "package.getCleanName()">' workflowTool = getToolByName(self, 'portal_workflow')
print >>outfile,''' __implements__=%(baseclass)s.__implements__+(%(realizations)s,)''' % \ {'baseclass':baseclass,'realizations':','.join(reparentnames)} print >> outfile
print >> outfile, ''' __implements__ = %(baseclass_interfaces)s + (%(realizations)s,)''' % \ {'baseclass_interfaces' : ' + '.join(['%s.__implements__' % i for i in parents.split(',')]), 'realizations' : ','.join(reparentnames)}
def generateClass(self, outfile, element, delayed): wrt = outfile.write wrt('\n')
aggregatedClasses = element.getRefs() + element.getSubtypeNames(recursive=0,filter=['class'])
aggregatedClasses = element.getRefs() + element.getSubtypeNames(recursive=1,filter=['class'])
def generateArchetypesClass(self, element,**kw): print indent('Generating class: '+element.getName(),self.infoind)
res = "ArrayField(%s)," % utils.indent(res, 2)
res = "ArrayField(%s),\n\n" % utils.indent(res, 2)
def getFieldFormatted(self, name, fieldtype, map={}, doc=None, indent_level=0, rawType='String', array_field=False): """Return the a formatted field definition for the schema. """
not element.hasStereoType(self.stereotype_cmfmember):
not element.hasStereoType(self.cmfmember_stereotype):
def generateClass(self, outfile, element, delayed): print indent('generating class: '+element.getName(),self.infoind)
map['validators']=expval
map['validators'] = '(' + ','.join(expval) + ',)'
def getFieldStringFromAttribute(self, attr, classelement, indent_level=0): ''' gets the schema field code ''' #print 'typename:%s:'%attr.getName(),attr.type,
path.append(self)
if not self.getPackage().hasStereoType('module'): path.append(self)
def getQualifiedModulePath(self,ref,pluginRoot='Products',forcePluginRoot=0): ''' returns the qualified name of the class, depending of the reference package 'ref' it generates an absolute path or a relative path if the pack(self) is a subpack of 'ref' if it belongs to a different root package it even needs a 'Products...
if a['id'] in (%(hideactions)s):
if a['id'] in [%(hideactions)s]:
def modify_fti(fti): # hide unnecessary tabs (usability enhancement) for a in fti['actions']: if a['id'] in (%(hideactions)s): a['visible'] = 0 return fti
'id': 'View', 'name': 'view',
'id': 'view', 'name': 'View',
def generateFti(self,element,subtypes): ''' '''
print z2implements_line
def generateImplements(self,element,parentnames): outfile = StringIO() # Zope 2 Interfaces # "__implements__" line -> handle realization parents reparents = element.getRealizationParents() z2reparentnames = [p.getName() for p in reparents if not p.hasStereoType('z3')] if z2reparentnames: z2iface_implements = \ ' + '.jo...
group.add_option("--detailed-created-permissions", type="yesno", help="""DEPRECATED: use --detailed-creation-permissions, which generates a slightly different syntax, though.""", default=0, section="CLASSES", dest="detailed_created_permissions", )
def handle_option_from_file(self, option_in_file, value_in_file, settings):
help="Use --detailed-creation-permission", action="deprecationwarning", section="DEPRECATED"
help="Use --detailed-creation-permissions", action="deprecationwarning", section="DEPRECATED" ) group.add_option("--detailed-created-permissions", type="yesno", help="Use" " --detailed-creation-permissions, which generates a" " slightly different syntax, though.", default=0, section="CLASSES", dest="detailed_created_p...
def handle_option_from_file(self, option_in_file, value_in_file, settings):
print >> outfile,' def %s(%s):' % (m.getName(),paramstr[1:])
print >> outfile,'\n def %s(%s):' % (m.getName(),paramstr[1:])
print >> outfile,' def %s(%s):' % (m.getName(),paramstr[1:])
print >> outfile, utils.indent('\n'+'pass',2)
print >> outfile, utils.indent('pass',2)
print >> outfile,' def %s(%s):' % (m.getName(),paramstr[1:])
wrt('
wrt('\n
def generateZope2Interface(self, element, **kw): outfile = StringIO() log.info("%sGenerating zope2 interface '%s'.", ' '*self.infoind, element.getName())
if not m.hasStereoType('tests', umlprofile=self.uml_profile)]
if not (m.hasStereoType('tests', umlprofile=self.uml_profile) or m.hasStereoType('stub', umlprofile=self.uml_profile))]
def generateProductInitPy(self, package): """ Generate __init__.py at product root from the DTML template"""
RCS-ID $Id: ArchGenXML.py,v 1.150 2004/04/27 00:06:15 yenzenz Exp $
RCS-ID $Id: ArchGenXML.py,v 1.151 2004/04/27 09:06:12 dpunktnpunkt Exp $
def generateInterface(self, outfile, element, delayed): wrt = outfile.write
def generateFti(self, element, subtypes): ''' generates Factory Type Information related attributes on the class'''
def generateActionsAndViews(self, element, subtypes): """Generate the views and actions (used to be in generateFti()) """
def generateFti(self, element, subtypes): ''' generates Factory Type Information related attributes on the class'''
if self.generateActions and hasActions: ftiTempl += actTempl
def generateFti(self, element, subtypes): ''' generates Factory Type Information related attributes on the class'''
widget=TextAreaWidget(),
def generateFti(self,element,subtypes): ''' '''
widget=RichWidget(),
def generateFti(self,element,subtypes): ''' '''
widget=FileWidget(),
def generateFti(self,element,subtypes): ''' '''
noparams=['documentation','element.uuid','transient','volatile']
noparams=['documentation','element.uuid','transient','volatile','widget']
def getFieldAttributes(self,element): ''' converts the tagged values of a field into extended attributes for the archetypes field ''' noparams=['documentation','element.uuid','transient','volatile'] convtostring=['expression'] lines=[] tgv=element.getTaggedValues() #print element.getName(),tgv for k in tgv.keys(): if k...
other_attributes=self.getFieldAttributes(attr)
other_attributes = (self.getWidget(ctype, attr) + self.getFieldAttributes(attr))
def getFieldStringFromAttribute(self, attr): ''' gets the schema field code ''' #print 'getFieldStringFromAttribute:',attr.getName(),attr.type if not hasattr(attr,'type') or attr.type=='NoneType': ctype='string' else: ctype=self.coerceType(str(attr.type))
f=self.makeFile(os.path.join(self.getSkinPath(klass),view_name+'.pt'),0)
f=self.makeFile(os.path.join(self.getSkinPath(element),view_name+'.pt'),0)
def generateMethodActions(self,element): outfile=StringIO() print >> outfile for m in element.getMethodDefs(): code=indent(m.getTaggedValue('code',''),1) if m.hasStereoType( ['action','view','form']): action_name=m.getTaggedValue('action','').strip() if not action_name: action_name=m.getTaggedValue(m.getStereoType(), m...
RCS-ID $Id: ArchGenXML.py,v 1.146 2004/04/24 15:36:04 xiru Exp $
RCS-ID $Id: ArchGenXML.py,v 1.147 2004/04/24 20:23:21 yenzenz Exp $
def generateInterface(self, outfile, element, delayed): wrt = outfile.write
settings[ALLOWED_OPTIONS_MAP[key][3]]=cp.get(ALLOWED_OPTIONS_MAP[key][2], key)
settings[ALLOWED_OPTIONS_MAP[key][3]]=cp.get(ALLOWED_OPTIONS_MAP[key][2], fkey)
def read_project_configfile(filename,settings): cp = ConfigParser() try: fname = open(filename,"r") except: print ARCHGENXML_VERSION_LINE print "\nERROR: Can't open project configuration file '%s'!", filename sys.exit(2) cp.readfp(fname) fname.close() for key in ALLOWED_OPTIONS_MAP.keys(): fkey = key[len(key)-1] == '...
INTERFACE="Foundation.Core.Interface"
def html2text(s,*args,**kwargs): return s
INTERFACE="UML:Interface"
def calcDatatype(self,att): global datatypes typeinfos=att.domElement.getElementsByTagName(XMI.TYPE) if len(typeinfos): classifiers=typeinfos[0].getElementsByTagName(XMI.CLASSIFIER) if len(classifiers): typeid=str(classifiers[0].getAttribute('xmi.idref')) typeElement=datatypes[typeid] #self.type=getAttributeValue(typeE...
continue
def buildRealizations(self,doc,objects): abs=doc.getElementsByTagName(XMI.ABSTRACTION)
pass
def buildRealizations(self,doc,objects): abs=doc.getElementsByTagName(XMI.ABSTRACTION)
buf=outfile.getvalue()
buf = outfile.getvalue() if isinstance(buf, unicode): buf = buf.encode('utf8')
def generatePackage(self, package, recursive=1): log.debug("Generating package %s.", package) if package.hasStereoType(self.stub_stereotypes, umlprofile=self.uml_profile): log.debug("It's a stub stereotyped package, skipping.") return package.generatedModules = [] if package.getName().lower().startswith('java') or not ...
""" \ returns a list of dictionaries. Each dict contains a key 'permission' with a string value and a key 'roles' with a list of strings as value.
""" return a list of dictionaries with permission definitions Each dict contains a key 'permission' with a string value and a key 'roles' with a list of strings as value and a key 'acquisition' with value 1 or 0.
def getPermissionsDefinitions(self): """ \ returns a list of dictionaries. Each dict contains a key 'permission' with a string value and a key 'roles' with a list of strings as value. """
pm = {'access' : 'Access contents information',
permission_mapping = {'access' : 'Access contents information',
def getPermissionsDefinitions(self): """ \ returns a list of dictionaries. Each dict contains a key 'permission' with a string value and a key 'roles' with a list of strings as value. """
tv = self.getTaggedValues() ret = [] for k, v in tv.items():
tagged_values = self.getTaggedValues() permission_definitions = [] for tag, tag_value in tagged_values.items():
def getPermissionsDefinitions(self): """ \ returns a list of dictionaries. Each dict contains a key 'permission' with a string value and a key 'roles' with a list of strings as value. """
if k in non_permissions or not v:
if tag in non_permissions or not tag_value:
def getPermissionsDefinitions(self): """ \ returns a list of dictionaries. Each dict contains a key 'permission' with a string value and a key 'roles' with a list of strings as value. """
k = k.strip()
tag = tag.strip()
def getPermissionsDefinitions(self): """ \ returns a list of dictionaries. Each dict contains a key 'permission' with a string value and a key 'roles' with a list of strings as value. """
permission = pm.get(k.lower(), k)
permission = permission_mapping.get(tag.lower(), tag)
def getPermissionsDefinitions(self): """ \ returns a list of dictionaries. Each dict contains a key 'permission' with a string value and a key 'roles' with a list of strings as value. """
roles = [str(r.strip()) for r in v.split(',') if r.strip()]
roles = [str(r.strip()) for r in tag_value.split(',') if r.strip()]
def getPermissionsDefinitions(self): """ \ returns a list of dictionaries. Each dict contains a key 'permission' with a string value and a key 'roles' with a list of strings as value. """
ret.append({'permission' : permission,
permission_definitions.append({'permission' : permission,
def getPermissionsDefinitions(self): """ \ returns a list of dictionaries. Each dict contains a key 'permission' with a string value and a key 'roles' with a list of strings as value. """
for r in ret: if r.get('permission', None) == pm['access']:
for permission_definition in permission_definitions: if (permission_definition.get('permission', None) == permission_mapping['access']):
def getPermissionsDefinitions(self): """ \ returns a list of dictionaries. Each dict contains a key 'permission' with a string value and a key 'roles' with a list of strings as value. """
if r.get('permission', None) == pm['view']: v = r
if (permission_definition.get('permission', None) == permission_mapping['view']): v = permission_definition
def getPermissionsDefinitions(self): """ \ returns a list of dictionaries. Each dict contains a key 'permission' with a string value and a key 'roles' with a list of strings as value. """
ret.append({'permission' : pm['access'], 'roles' : v['roles'], 'acquisition' : v['acquisition']})
permission = permission_mapping['access'] permission_definitions.append({'permission': permission, 'roles': v['roles'], 'acquisition': v['acquisition']}) return permission_definitions
def getPermissionsDefinitions(self): """ \ returns a list of dictionaries. Each dict contains a key 'permission' with a string value and a key 'roles' with a list of strings as value. """
return ret
def getPermissionsDefinitions(self): """ \ returns a list of dictionaries. Each dict contains a key 'permission' with a string value and a key 'roles' with a list of strings as value. """
(element.getProduct().getCleanName(),
(element.getPackage().getProduct().getCleanName(),
def generateArchetypesClass(self, element,**kw): """this is the all singing all dancing core generator logic for a full featured Archetypes class """ log.info("%sGenerating class '%s'.", ' '*self.infoind, element.getName()) name = element.getCleanName() # prepare file outfile=StringIO() wrt = outfile.write wrt('\n...
print >> outfile, actions_views
if actions_views: print >> outfile, actions_views
def generateArchetypesClass(self, element, **kw): """this is the all singing all dancing core generator logic for a full featured Archetypes class """ log.info("%sGenerating class '%s'.", ' '*self.infoind, element.getName())
permission=getExpression(m.getTaggedValue('permission')) if permission: print >> outfile,indent("security.declareProtected(%s,'%s')" % (permission,m.getName()),1)
if mode == 'class': permission=getExpression(m.getTaggedValue('permission')) if permission: print >> outfile,indent("security.declareProtected(%s,'%s')" % (permission,m.getName()),1)
def generateMethod(self,outfile,m,klass,mode='class'): #ignore actions and views here because they are #generated separately if m.hasStereoType(['action','view','form']): return #print 'generatemethod:',m.getStereoType(),m.getName() if m.hasStereoType('portlet_view'): view_name=m.getTaggedValue('view').strip() or m.ge...
check_map['description'] = "\'Enter a value for %s.\'" % widgetmap['label'][3:-3].lower()
check_map['description'] = "\'Enter a value for %s.\'" % widgetmap['label'].strip('"')
def getWidget(self, type, element, fieldname, elementclass): """ returns either default widget, widget according to attributes or no widget.
pprops = getToolByName(self, 'portal_properties', None)
props = getToolByName(self, 'portal_properties', None)
def install(self): """ External Method to install <dtml-var "package.getProductModuleName()"> """ out = StringIO() print >> out, "Installation log of %s:" % PROJECTNAME # If the config contains a list of dependencies, try to install # them. Add a list called DEPENDENCIES to your custom # AppConfig.py (imported by con...
res=self.genChildren
res=[c for c in self.genChildren]
def getGenChildren(self,recursive=0): ''' generalization children '''
res=self.genParents
res=[c for c in self.genParents]
def getGenParents(self,recursive=0): ''' generalization parents ''' res=self.genParents
res=self.realizationChildren
res=[c for c in self.realizationChildren]
def getRealizationChildren(self,recursive=0): ''' realization children '''
pass
ids = self.portal.objectIds()
def afterSetUp(self): pass
res=self.methodDefs
res=[m for m in self.methodDefs]
def getMethodDefs(self,recursive=0): res=self.methodDefs if recursive: parents=self.getGenParents(recursive=1) for p in parents: res.extend(p.getMethodDefs()) return res
line=line.split('|') line[0]=line[0].strip() if len(line)>1: line[1]=["'%s'" % r.strip() for r in line[1].split(',')] additional_permissions.append(line)
if len(line)>0: line=line.split('|') line[0]=line[0].strip() if len(line)>1: line[1]=["'%s'" % r.strip() for r in line[1].split(',')] additional_permissions.append(line)
def generateProductInitPy(self, package): """ Generate __init__.py at product root from the DTML template"""
<dtml-if "[klass for klass in package.getClasses(recursive=1) if klass.getTaggedValue('use_workflow')]">
<dtml-if "[klass for klass in generator.getGeneratedClasses(package) if generator.getOption('use_workflow', klass, None) is not None] and not klass.getStateMachines()">
def install(self): """ External Method to install <dtml-var "package.getProductModuleName()"> """ out = StringIO() print >> out, "Installation log of %s:" % PROJECTNAME # If the config contains a list of dependencies, try to install # them. Add a list called DEPENDENCIES to your custom # AppConfig.py (imported by con...
<dtml-in "package.getClasses(recursive=1)">
<dtml-in "generator.getGeneratedClasses(package)">
def install(self): """ External Method to install <dtml-var "package.getProductModuleName()"> """ out = StringIO() print >> out, "Installation log of %s:" % PROJECTNAME # If the config contains a list of dependencies, try to install # them. Add a list called DEPENDENCIES to your custom # AppConfig.py (imported by con...
<dtml-if "klass.getTaggedValue('use_workflow')"> wft.setChainForPortalTypes( ['<dtml-var "klass.getCleanName()">'],'<dtml-var "klass.getTaggedValue('use_workflow')">')
<dtml-if "generator.getOption('use_workflow', klass, None) is not None and not klass.getStateMachine()"> wft.setChainForPortalTypes( ['<dtml-var "klass.getCleanName()">'], <dtml-var "utils.getExpression(generator.getOption('use_workflow', klass))">)
def install(self): """ External Method to install <dtml-var "package.getProductModuleName()"> """ out = StringIO() print >> out, "Installation log of %s:" % PROJECTNAME # If the config contains a list of dependencies, try to install # them. Add a list called DEPENDENCIES to your custom # AppConfig.py (imported by con...
if self.noclass: return
def generateProduct(self, root): dirMode=0 outfile=None
packageImports = [m.getModuleName() for m in package.getAnnotation('generatedPackages') if not m.hasStereoType('tests') or []]
packageImports = [m.getModuleName() for m in package.getAnnotation('generatedPackages') or [] if not m.hasStereoType('tests')]
def generateProductInitPy(self, package): """ Generate __init__.py at product root from the DTML template"""
if m.getStereoType() in ['action','view']:
if m.getStereoType() in ['action','view','form']:
def generateMethod(self,outfile,m,klass): #ignore actions and views here because they are #generated separately if m.getStereoType() in ['action','view']: return #print 'generatemethod:',m.getStereoType(),m.getName() if m.getStereoType()=='portlet_view': view_name=m.getTaggedValue('view').strip() or m.getName() print ...
self.msgcatstack.append(msgcatalog.MessageCatalog( filename=filepath ))
self.msgcatstack.append(msgcatalog.MessageCatalog( filename=os.path.join(self.targetRoot, filepath) ))
def generateProduct(self, root, ): dirMode=0 outfile=None
if element.isInternal() or element.hasStereoType(self.stub_stereotypes):
if element.isInternal() or element.hasStereoType(self.stub_stereotypes) or \ element.getName() in self.hide_classes:
def generatePackage(self,package,recursive=1):
log.info("%sGenerating python class '%s'.", ' ',
log.debug("Generating python class '%s'.",
def generatePythonClass(self, element, template, **kw): log.info("%sGenerating python class '%s'.", ' ', element.getName()) templ = utils.readTemplate(template) d = { 'klass': element, 'generator': self, 'parsed_class': element.parsed_class, 'builtins': __builtins__, 'utils': utils, } d.update(__builtins__) d.updat...
toolNames = [c.getQualifiedName(package) for c in
toolNames = [c.getQualifiedName(package, includeRoot=0) for c in
def generateProductInitPy(self, package): """ Generate __init__.py at product root from the DTML template"""
def getFieldFormatted(self, name, fieldtype, map={}, doc=None, rawType='String', indent_level=0):
def getFieldFormatted(self,name,fieldtype,map={},doc=None, indent_level=0, rawType='String'):
def getFieldFormatted(self, name, fieldtype, map={}, doc=None, rawType='String', indent_level=0): """Return the formatted field definitions for the schema. """
log.debug("Trying to get formatted field. name='%s', fieldtype='%', "
log.debug("Trying to get formatted field. name='%s', fieldtype='%s', "
def getFieldFormatted(self, name, fieldtype, map={}, doc=None, rawType='String', indent_level=0): """Return the formatted field definitions for the schema. """
linebreak = lines.find('\n') if linebreak < 0: linebreak=len(lines) firstline = lines[:linebreak]
if type(lines) in StringTypes: linebreak = lines.find('\n') if linebreak < 0: linebreak=len(lines) firstline = lines[:linebreak] else: firstline = lines
def getFieldFormatted(self, name, fieldtype, map={}, doc=None, rawType='String', indent_level=0): """Return the formatted field definitions for the schema. """
if linebreak<len(lines):
if type(lines) in StringTypes and linebreak<len(lines):
def getFieldFormatted(self, name, fieldtype, map={}, doc=None, rawType='String', indent_level=0): """Return the formatted field definitions for the schema. """
dict["list_name"] = \ str(site.getElementsByTagName("dirname")[0].firstChild.nodeValue) dict["host"] = \ str(site.getElementsByTagName("host")[0].firstChild.nodeValue) dict["basename"] = \ str(site.getElementsByTagName("basename")[0].firstChild.nodeValue)
dirname_child = site.getElementsByTagName("dirname")[0].firstChild dict["list_name"] = dirname_child.nodeValue.encode("utf-8") host_child = site.getElementsByTagName("host")[0].firstChild dict["host"] = host_child.nodeValue.encode("utf-8") basename_child = site.getElementsByTagName("basename")[0].firstChild dict["bas...
def __getConfigSiteDict(self,site): dict = {} dict["list_name"] = \ str(site.getElementsByTagName("dirname")[0].firstChild.nodeValue) dict["host"] = \ str(site.getElementsByTagName("host")[0].firstChild.nodeValue) dict["basename"] = \ str(site.getElementsByTagName("basename")[0].firstChild.nodeValue)
dict["username"] = site.getElementsByTagName("username")
username = site.getElementsByTagName("username")
def __getConfigSiteDict(self,site): dict = {} dict["list_name"] = \ str(site.getElementsByTagName("dirname")[0].firstChild.nodeValue) dict["host"] = \ str(site.getElementsByTagName("host")[0].firstChild.nodeValue) dict["basename"] = \ str(site.getElementsByTagName("basename")[0].firstChild.nodeValue)
if dict["username"].length == 1: dict["username"] = str(dict["username"][0].firstChild.nodeValue)
if username.length == 1: dict["username"] = username[0].firstChild.nodeValue.encode("utf-8")
def __getConfigSiteDict(self,site): dict = {} dict["list_name"] = \ str(site.getElementsByTagName("dirname")[0].firstChild.nodeValue) dict["host"] = \ str(site.getElementsByTagName("host")[0].firstChild.nodeValue) dict["basename"] = \ str(site.getElementsByTagName("basename")[0].firstChild.nodeValue)
password = str(password[0].firstChild.nodeValue)
password = password[0].firstChild.nodeValue.encode("utf-8")
def __getConfigSiteDict(self,site): dict = {} dict["list_name"] = \ str(site.getElementsByTagName("dirname")[0].firstChild.nodeValue) dict["host"] = \ str(site.getElementsByTagName("host")[0].firstChild.nodeValue) dict["basename"] = \ str(site.getElementsByTagName("basename")[0].firstChild.nodeValue)
r = self.__parseFile("/etc/group")
r = self.__parseFile(self.config.buildroot + "/etc/group")
def getGID(self, groupname): """Return GID for groupname, or 0 if unknown."""
self.config.printWarning(1, "%s: File doesn't exist" % rfi.filename)
def __verifyFileInstall(self, rfi, db, pathPrefix=''): """Return 1 if file with RpmFileInfo rfi should be installed.
pkgs = findPkgByName([pkgname,], self.db.getPkgList())
pkgs = findPkgByNames([pkgname,], self.db.getPkgList())
def erasePackage(self, pkgname): """Append the best match for pkgname to self.rpms.
self.config.printInfo(0, "fileconflict checking took %s seconds\n" % (clock() - time1))
self.config.printInfo(0, "fileconflict checking took %s seconds\n" % (time.clock() - time1))
def getFileConflicts(self): """Find file conflicts among packages in self.list.
en = "%s:%s" % (e, n) ena = "%s:%s" % (e, na) env = "%s:%s" % (e, nv) enva = "%s:%s" % (e, nva) envr = "%s:%s" % (e, nvr) envra = "%s:%s" % (e, nvra) for item in (n, na, nv, nva, nvr, nvra, en, ena, env, enva, envr, envra):
for item in (n, na, nv, nva, nvr, nvra):
def buildPkgRefDict(pkgs): """Take a list of RpmPackage's and return a dict that contains all the possible naming conventions for them (name=>RpmPackage): name, name.arch, name-version-release.arch, name-version, name-version-release, epoch:name-version-release.""" pkgdict = {} for pkg in pkgs: (n, e, v, r, a) = (pkg[...
del self.obsoletes_list
def __init__(self, config, source, buildroot=None): memorydb.RpmMemoryDB.__init__(self, config, source, buildroot) rpmdb.RpmDB.__init__(self, config, source, buildroot)
def __init__(self, filename=None, verify=None, verbose=None, legacy=None, payload=None, parsesig=None, tags=None, ntags=None, keepdata=None):
def __init__(self, filename=None, verify=None, verbose=None, legacy=None, payload=None, parsesig=None, hdronly=None, tags=None, ntags=None, keepdata=None):
def __init__(self, filename=None, verify=None, verbose=None, legacy=None, payload=None, parsesig=None, tags=None, ntags=None, keepdata=None): RpmIO.__init__(self) self.filename = filename self.fd = None self.verify = verify self.verbose = verbose self.legacy = legacy self.payload = payload self.parsesig = parsesig self...
return data["filetree"] = []
return data["filetree"]
def parseFilelist(self, data): if data["dirnames"] == None or data["dirindexes"] == None: return data["filetree"] = [] for i in xrange (len(data["basenames"])): if self.verify: data["filetree"].append((data["dirnames"][data["dirindexes"][i]] + data["basenames"][i], data["fileflags"][i], data["fileinodes"][i], data["fil...
if info_max < 2:
if info_max < 0:
def __init__(self, info_max=5, debug_max=10): """ Logger class initialization """ self._level = 0 self._debug_level = 0 self._format = "" self._date_format = "" self._label = { } self._logging = { } self._domains = { }
if debug_max < 2:
if debug_max < 0:
def __init__(self, info_max=5, debug_max=10): """ Logger class initialization """ self._level = 0 self._debug_level = 0 self._format = "" self._date_format = "" self._label = { } self._logging = { } self._domains = { }
self._checkLogLevel(level, min=self.FATAL, max=self.INFO_MAX)
if level < self.NO_LOG: level = self.NO_LOG if level > self.INFO_MAX: level = self.INFO_MAX
def setLogLevel(self, level): """ Set log level [NOTHING .. INFO_MAX] """ self._checkLogLevel(level, min=self.FATAL, max=self.INFO_MAX) self._level = level
self._checkLogLevel(level-self.NO_DEBUG, min=0, max=self.DEBUG_MAX-self.NO_DEBUG)
if level < 0: level = 0 if level > self.DEBUG_MAX - self.NO_DEBUG: level = self.DEBUG_MAX - self.NO_DEBUG
def setDebugLogLevel(self, level): """ Set debug log level [NO_DEBUG .. DEBUG_MAX] """ self._checkLogLevel(level-self.NO_DEBUG, min=0, max=self.DEBUG_MAX-self.NO_DEBUG) self._debug_level = level - self.NO_DEBUG
if _len >= len(domain): if not module_name.startswith(domain):
elif i > 0: d = domain[:i] else: d = domain if _len >= len(d): if not module_name.startswith(d):
def _log(self, level, newline, raw, format, *args): """ Internal log function. """ # log level higher than logging level? if level > self.INFO_MAX: if level-self.INFO_MAX > self._debug_level: return else: if level > self._level: return
if not domain.startswith(module_name):
if not d.startswith(module_name):
def _log(self, level, newline, raw, format, *args): """ Internal log function. """ # log level higher than logging level? if level > self.INFO_MAX: if level-self.INFO_MAX > self._debug_level: return else: if level > self._level: return
sigkeys = [rpmtag["dsaheader"], rpmtag["gpg"]] sigkeys2 = [rpmtag["pgp"], rpmtag["badsha1_2"]] reqsig = [rpmtag["header_signatures"], rpmtag["payloadsize"], rpmtag["size_in_sig"], rpmtag["sha1header"], rpmtag["md5"]]
def getTag(tag): """Find the integer tag.""" import types if isinstance(tag, types.IntType): return tag elif isinstance(tag, types.StringType): if tag[:3] == "RPM": return eval("rpmconstants.%s" % tag) else: if rpmtag.has_key(tag): return rpmtag[tag] return eval("rpmconstants.RPMTAG_%s" % tag.upper()) return None
if prog not in (None, "/bin/sh", "/sbin/ldconfig", "/usr/bin/fc-cache",
if script == None and prog == None: return (None, None) if prog not in ("/bin/sh", "/sbin/ldconfig", "/usr/bin/fc-cache",
def getScript(self, s, p): script = self.getItem(s) prog = self.getItem(p) if script and not prog: self.raiseErr("no prog") if prog not in (None, "/bin/sh", "/sbin/ldconfig", "/usr/bin/fc-cache", "/usr/sbin/glibc_post_upgrade", "/usr/sbin/libgcc_post_upgrade", "/usr/sbin/build-locale-archive", "/usr/bin/scrollkeeper-up...