rem stringlengths 0 322k | add stringlengths 0 2.05M | context stringlengths 8 228k |
|---|---|---|
self._p_changed = 1 util.redirect(RESPONSE, 'atse_editor', | self._schemas[schema_id] = S util.redirect(RESPONSE, schema_template, | def atse_schemataMoveLeft(self, schema_id, name, RESPONSE=None): """ move a schemata to the left""" S = self.atse_getSchemaById(schema_id) S.moveSchemata(name, -1) self._p_changed = 1 util.redirect(RESPONSE, 'atse_editor', self.translate('atse_moved_left', default='Schemata moved to left'), schema_id=schema_id, schemat... |
def atse_schemataMoveRight(self, schema_id, name, RESPONSE=None): | def atse_schemataMoveRight(self, schema_id, schema_template, name, RESPONSE=None): | def atse_schemataMoveRight(self, schema_id, name, RESPONSE=None): """ move a schemata to the right""" S = self.atse_getSchemaById(schema_id) S.moveSchemata(name, 1) self._p_changed = 1 util.redirect(RESPONSE, 'atse_editor', self.translate('atse_moved_right', default='Schemata moved to right'), schema_id=schema_id, sche... |
self._p_changed = 1 util.redirect(RESPONSE, 'atse_editor', | self._schemas[schema_id] = S util.redirect(RESPONSE, schema_template, | def atse_schemataMoveRight(self, schema_id, name, RESPONSE=None): """ move a schemata to the right""" S = self.atse_getSchemaById(schema_id) S.moveSchemata(name, 1) self._p_changed = 1 util.redirect(RESPONSE, 'atse_editor', self.translate('atse_moved_right', default='Schemata moved to right'), schema_id=schema_id, sche... |
def atse_fieldMoveLeft(self, schema_id, name, RESPONSE=None): | def atse_fieldMoveLeft(self, schema_id, schema_template, name, RESPONSE=None): | def atse_fieldMoveLeft(self, schema_id, name, RESPONSE=None): """ move a field of a schemata to the left""" S = self.atse_getSchemaById(schema_id) S.moveField(name, -1) self._p_changed = 1 util.redirect(RESPONSE, 'atse_editor', self.translate('atse_field_moved_up', default='Field moved up'), schemata=S[name].schemata, ... |
self._p_changed = 1 util.redirect(RESPONSE, 'atse_editor', | self._schemas[schema_id] = S util.redirect(RESPONSE, schema_template, | def atse_fieldMoveLeft(self, schema_id, name, RESPONSE=None): """ move a field of a schemata to the left""" S = self.atse_getSchemaById(schema_id) S.moveField(name, -1) self._p_changed = 1 util.redirect(RESPONSE, 'atse_editor', self.translate('atse_field_moved_up', default='Field moved up'), schemata=S[name].schemata, ... |
def atse_fieldMoveRight(self, schema_id, name, RESPONSE=None): | def atse_fieldMoveRight(self, schema_id, schema_template, name, RESPONSE=None): | def atse_fieldMoveRight(self, schema_id, name, RESPONSE=None): """ move a field of a schemata to the right""" S = self.atse_getSchemaById(schema_id) S.moveField(name, 1) self._p_changed = 1 util.redirect(RESPONSE, 'atse_editor', self.translate('atse_field_moved_down', default='Field moved down'), schemata=S[name].schem... |
self._p_changed = 1 util.redirect(RESPONSE, 'atse_editor', | self._schemas[schema_id] = S util.redirect(RESPONSE, schema_template, | def atse_fieldMoveRight(self, schema_id, name, RESPONSE=None): """ move a field of a schemata to the right""" S = self.atse_getSchemaById(schema_id) S.moveField(name, 1) self._p_changed = 1 util.redirect(RESPONSE, 'atse_editor', self.translate('atse_field_moved_down', default='Field moved down'), schemata=S[name].schem... |
def atse_changeSchemataForField(self, schema_id, name, schemata_name, RESPONSE=None): | def atse_changeSchemataForField(self, schema_id, schema_template, name, schemata_name, RESPONSE=None): | def atse_changeSchemataForField(self, schema_id, name, schemata_name, RESPONSE=None): """ move a field from the current fieldset to another one """ S = self.atse_getSchemaById(schema_id) S.changeSchemataForField(name, schemata_name) self._p_changed = 1 util.redirect(RESPONSE, 'atse_editor', self.translate('atse_field_m... |
self._p_changed = 1 util.redirect(RESPONSE, 'atse_editor', | self._schemas[schema_id] = S util.redirect(RESPONSE, schema_template, | def atse_changeSchemataForField(self, schema_id, name, schemata_name, RESPONSE=None): """ move a field from the current fieldset to another one """ S = self.atse_getSchemaById(schema_id) S.changeSchemataForField(name, schemata_name) self._p_changed = 1 util.redirect(RESPONSE, 'atse_editor', self.translate('atse_field_m... |
self.r = {'submitter' : {'email': issue.getContact_email()}} | self.r = {'submitter' : {'email': issue.Schema()['contact_email'].get(issue)}} | def __init__(self, issue): self.issue = issue self.collector = self.issue._getCollector() |
self.r[email] = {'email': issue.getContact_email()} | self.r[email] = {'email': issue.Schema()['contact_email'].get(issue)} | def __init__(self, issue): self.issue = issue self.collector = self.issue._getCollector() |
email_msg = '' print recipients dest_emails = [ v['email'] for v in recipients.values() if v.get('email','') != ''] | dest_emails = [ v['email'] for v in recipients.values() if util.isValidEmailAddress(v.get('email','')) ] outer = MIMEMultipart() outer['From'] = collector.collector_email outer['To'] = ','.join(dest_emails) subject = '[%s] subject = str(Header(subject, 'iso-8859-1')) outer['Subject'] = subject outer['Content-Type'] = ... | def send_notifications(recipients, issue): """ send out notifications through email """ collector = issue.aq_parent |
print dest_emails | def send_notifications(recipients, issue): """ send out notifications through email """ collector = issue.aq_parent | |
mh._send(collector.collector_email, dest_emails, email_msg.as_string()) | mh._send(collector.collector_email, dest_emails, outer.as_string()) | def send_notifications(recipients, issue): """ send out notifications through email """ collector = issue.aq_parent |
def manage_beforeDelete(self,object,container): self.uninstall() | def manage_beforeDelete(self,object,container): self.uninstall() | |
return self.update(self, **kwargs) | return self.update(**kwargs) | def edit(self, *args, **kwargs): """Reimplementing edit() to have a compatibility method for the old cmf edit() method """ if len(args) != 0: # use cmf edit method return self.cmf_edit(*args, **kwargs) fieldNames = [field.getName() for field in self.Schema().fields()] for name in kwargs.keys(): if name not in fieldNam... |
lst.sort(lambda x,y: cmp(int(x[1]), int(y[1]))) | lst.sort(mysort) | def query_sort(a, b): """ helper method to sort the result list """ va = getattr(a, sort_on); vb = getattr(b, sort_on) # try to convert the values to ints try: va = int(va); vb = int(vb) except: pass if sort_direction == 'desc': return -1 * cmp(va, vb) else: return cmp(va, vb) |
self._transcript.addComment(TR('reference_removed', 'Reference removed: %s' % issue_url)) | self._transcript.addComment(self.Translate('reference_removed', u'Reference removed: %s' % issue_url, as_unicode=1)) | def delete_reference(self, issue_url, RESPONSE=None): """ delete a reference given by its position """ |
security.declareProtected(ManageCollector, 'upload_remove') def upload_remove(self, id, RESPONSE): | security.declareProtected(ManageCollector, 'remove_upload') def remove_upload(self, id, RESPONSE): | def upload_file(self, uploaded_file=None, comment='', srcname='', mimetype='', notify=1, RESPONSE=None): """ Upload a file """ |
self._transcript.addComment(TR('upload_removed', 'Removed: %s' % id)) | self._transcript.addComment(self.Translate('upload_removed', 'Removed: %s' % id, as_unicode=1)) | def upload_remove(self, id, RESPONSE): """ Remove an uploaded file """ self.manage_delObjects([id]) self._transcript.addComment(TR('upload_removed', 'Removed: %s' % id)) util.redirect(RESPONSE, 'pcng_issue_uploads', self.Translate('upload_removed', 'File has been removed')) |
elif self.quota_aware: | elif self.quota_maxbytes != 0: | def unpackFile(self, plfngRelativeDir, FSpackedFile, REQUEST, RESPONSE): """ unpack a file """ |
try: unpackedSize = int(getMetadataElement(FSpackedFile, section="ARCHIVEINFO", option="unpacked_size")) except: | unpackedSizeStr = getMetadataElement(FSpackedFile, section="ARCHIVEINFO", option="unpacked_size") if unpackedSizeStr: try: unpackedSize = int(unpackedSizeStr.split('.')[0]) except: unpackedSize = 0 else: | def unpackFile(self, plfngRelativeDir, FSpackedFile, REQUEST, RESPONSE): """ unpack a file """ |
unpackedSize = int(getMetadataElement(FSpackedFile, section="ARCHIVEINFO", option="unpacked_size") ) | unpackedSizeStr = getMetadataElement(FSpackedFile, section="ARCHIVEINFO", option="unpacked_size") try: unpackedSize = int(unpackedSizeStr.split('.')[0]) except: unpackedSize = 0 | def unpackFile(self, plfngRelativeDir, FSpackedFile, REQUEST, RESPONSE): """ unpack a file """ |
raise ValueError(self.translate('atse_feld_not_deleteable', | raise ValueError(self.translate('atse_field_not_deleteable', | def atse_delField(self, name, RESPONSE=None): """ remove a field from a schemata""" |
util.redirect(RESPONSE, 'pcng_schema_editor', 'Field changed', | util.redirect(RESPONSE, 'pcng_schema_editor', self.translate('atse_field_changed', 'Field changed'), | def atse_update(self, fielddata, REQUEST, RESPONSE=None): """ update a single field""" |
ids = OIBTree() for id in lids.keys(): o = self._getOb(id) if o.ContainmentMetaType() in spec: ids[id]=lids[id] set = union(set, ids) | if lids is not None: ids = OIBTree() for id in lids.keys(): o = self._getOb(id) if o.ContainmentMetaType() in spec: ids[id]=lids[id] set = union(set, ids) | def new_BTreeobjectIds(self, spec=None): # Returns a list of subobject ids of the current object. # If 'spec' is specified, returns objects whose meta_type # matches 'spec'. # we also match i18nlayer subobjects here which match spec if spec is not None: if isinstance(spec, StringType): spec = [spec] mti = self._mt_in... |
def _processForm(self, data=1, metadata=None, REQUEST=None): | def _processForm(self, data=1, metadata=None, REQUEST=None,values=None): | def _processForm(self, data=1, metadata=None, REQUEST=None): |
RESPONSE.setStatus(401) | RESPONSE.setStatus(status) | def response(RESPONSE, status, msg): if RESPONSE: RESPONSE.setStatus(401) RESPONSE.write(msg) else: raise ValueError(msg) |
if event.getUser() != last_user or event.getTimestamp() - last_ts > 60 or event.getType() == 'comment': | if event.getUser() != last_user or event.getTimestamp() - last_ts > 60 or event.getType() in ('comment', ): | def getEventsGrouped(self, reverse=1): """ return all events grouped by their timestamp """ |
def updateMD5Metadatum(self, PLFNGrelativePath, mode='testonly'): """ update a metadatum for the file """ | def updateMD5Metadatum(self, PLFNGrelativePath='', mode='testonly'): """ update (or test) the MD5 metadatum for the file """ | def updateMD5Metadatum(self, PLFNGrelativePath, mode='testonly'): """ update a metadatum for the file """ # if REQUEST param exists, this method uses the rel_dir from # the '_e' field of REQUEST, and the result of the method is # provided via redirect portal_status_message output. # # Otherwise, this method returns one... |
targetFile = self._getFSFullPath(PLFNGRelativePath='') | targetFile = self._getFSFullPath(PLFNGRelativePath=PLFNGrelativePath) | def updateMD5Metadatum(self, PLFNGrelativePath, mode='testonly'): """ update a metadatum for the file """ # if REQUEST param exists, this method uses the rel_dir from # the '_e' field of REQUEST, and the result of the method is # provided via redirect portal_status_message output. # # Otherwise, this method returns one... |
proxy.setLanguage(GENERAL_MD.get('language','natural')) | DIAGNOSTICS_MD = getMetadataElements(fullpath, 'DIAGNOSTICS') or {} proxy.setChecksum(GENERAL_MD.get('md5','')) | def _createProxy(self, id, **kw): """ handle the details, nassty """ from os.path import join, dirname, exists destination = kw['destination'] proxy_type = kw.get('type', 'content') properties = kw.get('properties', None) rel_dir = kw['rel_dir'] |
uploadFileBaseName = os.path.basename(upload.filename) | if '\\' in upload.filename: filename = upload.filename.split('\\')[-1] else: filename = upload.filename uploadFileBaseName = os.path.basename(filename) | def HTMLFormUploadFile(self, upload, comment, clientMD5=None): """ upload a file via HTML form-based file upload mechanism """ |
filename = os.path.join(destpath, os.path.basename(upload.filename)) tmpfile = filename + '.plfngtmp' | destFSfullPath = os.path.join(destpath, os.path.basename(filename)) tmpfile = destFSfullPath + '.plfngtmp' | def HTMLFormUploadFile(self, upload, comment, clientMD5=None): """ upload a file via HTML form-based file upload mechanism """ |
destBasename=os.path.basename(filename), | destBasename=os.path.basename(destFSfullPath), | def HTMLFormUploadFile(self, upload, comment, clientMD5=None): """ upload a file via HTML form-based file upload mechanism """ |
setMetadata(filename, | setMetadata(destFSfullPath, | def HTMLFormUploadFile(self, upload, comment, clientMD5=None): """ upload a file via HTML form-based file upload mechanism """ |
filename=upload.filename.lower()) == 'application/zip': | filename=filename.lower()) == 'application/zip': | def HTMLFormUploadFile(self, upload, comment, clientMD5=None): """ upload a file via HTML form-based file upload mechanism """ |
if hasattr(self, "hidden_file_prefixes") and self.hidden_file_prefixes: filePrefixesSkipList = split(self.hidden_file_prefixes,',') else: filePrefixesSkipList = [] if hasattr(self, "hidden_file_suffixes") and self.hidden_file_suffixes: fileSuffixesSkipList = split(self.hidden_file_suffixes,',') else: fileSuffixesSkipL... | filePrefixesSkip = self._getAttribute('hidden_file_prefixes') fileSuffixesSkip = self._getAttribute('hidden_file_suffixes') fileNamesSkip = self._getAttribute('hidden_file_names') folderPrefixesSkip = self._getAttribute('hidden_folder_prefixes') folderSuffixesSkip = self._getAttribute('hidden_folder_suffixes') folderNa... | def getFilteredContents(self,rel_dir=None): """ list filtered content of local filesystem """ |
filePrefixesSkipList=filePrefixesSkipList, fileSuffixesSkipList=fileSuffixesSkipList, fileNamesSkipList=fileNamesSkipList, folderPrefixesSkipList=folderPrefixesSkipList, folderSuffixesSkipList=folderSuffixesSkipList, folderNamesSkipList=folderNamesSkipList) | filePrefixesSkipList=filePrefixesSkip, fileSuffixesSkipList=fileSuffixesSkip, fileNamesSkipList=fileNamesSkip, folderPrefixesSkipList=folderPrefixesSkip, folderSuffixesSkipList=folderSuffixesSkip, folderNamesSkipList=folderNamesSkip) | def getFilteredContents(self,rel_dir=None): """ list filtered content of local filesystem """ |
uninstall(self, out) | uninstall_tool(self, out) | def install_tool(self, out): if hasattr(self, TOOL_ID): uninstall(self, out) self.manage_addProduct['CompositePack'].manage_addCompositeTool() out.write("CompositePack Tool Installed") |
def definition(txt): | def definition(txt, style=DefStyle): | def definition(txt): assert isinstance(txt, UnicodeType) p = XPreformatted(utf8(txt), DefStyle) Elements.append(p) |
p = XPreformatted(utf8(txt), DefStyle) | p = XPreformatted(utf8(txt), style) | def definition(txt): assert isinstance(txt, UnicodeType) p = XPreformatted(utf8(txt), DefStyle) Elements.append(p) |
header(translate('issue_number', 'Issue | header(break_longlines(translate('issue_number', 'Issue | def getFieldValue(issue, field): v = issue.Schema()[field].get(issue) if isinstance(v, StringType): return unicode(v, collector.getSiteEncoding()) return v |
definition(html_quote(getFieldValue(issue, 'description'))) | definition(html_quote(getFieldValue(issue, 'description')), PreStyle) | def getFieldValue(issue, field): v = issue.Schema()[field].get(issue) if isinstance(v, StringType): return unicode(v, collector.getSiteEncoding()) return v |
dummy,method = vocab[0].split(',') | dummy,method = vocab[0].split(':') | def schema_update(self, fielddata, REQUEST, RESPONSE=None): """ update a single field""" |
self.translate('atse_field_deleted', 'Field deleted'), fieldset=return_schemata) | self.translate('atse_field_deleted', 'Field deleted'), schemata=return_schemata) | def atse_delField(self, name, RESPONSE=None): """ remove a field from a schemata""" |
if R.has_key('atse_add_field'): | if R.has_key('add_field'): | def atse_update(self, fielddata, REQUEST, RESPONSE=None): """ update a single field""" |
fields = self._schemas[fieldset].fields() fields.append(StringField(R['name'], schemata=fieldset, widget=StringWidget)) schema = OrderedSchema() for f in fields: schema.addField(f) self._schemas[fieldset] = schema | field = StringField(R['name'], schemata=fieldset, widget=StringWidget) self._ms.addField(field) self._p_changed = 1 | def atse_update(self, fielddata, REQUEST, RESPONSE=None): """ update a single field""" |
self.translate('atse_field_added', 'Field added'), fieldset=fieldset, field=R['name']) | self.translate('atse_field_added', 'Field added'), schemata=fieldset, field=R['name']) | def atse_update(self, fielddata, REQUEST, RESPONSE=None): """ update a single field""" |
field = field(FD.name, **D) schema = self._schemas[FD.schemata] new_schema = OrderedSchema() for f in schema.fields(): if f.getName() == FD.name: new_schema.addField(field) else: new_schema.addField(f) self._schemas[FD.schemata] = new_schema | f = field(FD.name, **D) oldfield = self._ms[FD.name] f._index = oldfield._index self._ms[FD.name] = f | def atse_update(self, fielddata, REQUEST, RESPONSE=None): """ update a single field""" |
fieldset=FD.schemata, field=FD.name) | schemata=FD.schemata, field=FD.name) | def atse_update(self, fielddata, REQUEST, RESPONSE=None): """ update a single field""" |
self.translate('atse_field_moved', 'Field moved to other fieldset'), fieldset=schemata_name, field=name) | self.translate('atse_field_moved', 'Field moved to other fieldset'), schemata=schemata_name, field=name) | def atse_changeSchemataForField(self, name, schemata_name, RESPONSE=None): """ move a field from the current fieldset to another one """ self._ms.changeSchemataForField(name, schemata_name) self._p_changed = 1 util.redirect(RESPONSE, 'pcng_schema_editor', self.translate('atse_field_moved', 'Field moved to other fieldse... |
return self.Users.acl_users._doDelUsers(name) | return self.Users.acl_users._doDelUsers(names) | def _doDelUsers(self, names): """Delete one or more users. This should be implemented by subclasses to do the actual deleting of users.""" return self.Users.acl_users._doDelUsers(name) |
return field.storage.get(key, self) | try: return field.storage.get(key, self) except: return '' | def getParameter(self, key): """ return the value of an Archetypes field """ |
for name in issue.atse_getSchemataNames(): | for name in issue.atse_getSchemataNames(SCHEMA_ID): | def getFieldValue(issue, field): v = issue.getField(field).get(issue) if isinstance(v, StringType) or isinstance(v, UnicodeType): v = v.replace(chr(13), '') if isinstance(v, StringType): return unicode(v, collector.getSiteEncoding()) return v |
for field in issue.atse_getSchemata(name).fields(): | for field in issue.atse_getSchemata(SCHEMA_ID, name).fields(): | def getFieldValue(issue, field): v = issue.getField(field).get(issue) if isinstance(v, StringType) or isinstance(v, UnicodeType): v = v.replace(chr(13), '') if isinstance(v, StringType): return unicode(v, collector.getSiteEncoding()) return v |
print schema | def schema_update(self, REQUEST, RESPONSE=None): """ update a schema schema """ | |
issue_url=issue.absolute_url(), | issue_url=issue.absolute_url(1), | def add_reference(self, reference, RESPONSE=None): """ add a new reference (record object) """ |
catalogs = [getattr(self, 'pcng_catalog'), getToolByName(self, 'portal_catalog', None)] for c in catalogs: c.indexObject(self) | self.pcng_catalog.indexObject(self) from Products.Archetypes.config import TOOL_NAME at = getToolByName(self, TOOL_NAME , None) for c in at.getCatalogsByType(self.meta_type): if c.getId() in 'portal_catalog': continue c.catalog_object(self, '/'.join(self.getPhysicalPath())) | def reindexObject(self, idxs=None): """ reindex issue """ catalogs = [getattr(self, 'pcng_catalog'), getToolByName(self, 'portal_catalog', None)] for c in catalogs: c.indexObject(self) |
catalogs = [getattr(self, 'pcng_catalog'), getToolByName(self, 'portal_catalog', None)] for c in catalogs: c.unindexObject(self) | self.pcng_catalog.unindexObject(self) catalogs = [getattr(self, 'pcng_catalog')] from Products.Archetypes.config import TOOL_NAME at = getToolByName(self, TOOL_NAME , None) for c in at.getCatalogsByType(self.meta_type): if c.getId() in 'portal_catalog': continue c.uncatalog_object('/'.join(self.getPhysicalPath())) | def unindexObject(self): catalogs = [getattr(self, 'pcng_catalog'), getToolByName(self, 'portal_catalog', None)] for c in catalogs: c.unindexObject(self) |
def CopyWithInsertion(input, commentPrefix, retainDefs, *lists): | def CopyWithInsertion(input, commentPrefix, retainDefs, eolType, *lists): | def CopyWithInsertion(input, commentPrefix, retainDefs, *lists): copying = 1 listid = 0 output = [] for line in input.split("\n"): isStartGenerated = line.startswith(commentPrefix + "++Autogenerated") if copying and not isStartGenerated: output.append(line) if isStartGenerated: if retainDefs: output.append(line) copyin... |
for line in input.split("\n"): | for line in input.splitlines(0): | def CopyWithInsertion(input, commentPrefix, retainDefs, *lists): copying = 1 listid = 0 output = [] for line in input.split("\n"): isStartGenerated = line.startswith(commentPrefix + "++Autogenerated") if copying and not isStartGenerated: output.append(line) if isStartGenerated: if retainDefs: output.append(line) copyin... |
ret = "\n".join(output) ret = ret.replace(" \n", "\n") return ret | output = [line.rstrip(" \t") for line in output] return eolType.join(output) + eolType | def CopyWithInsertion(input, commentPrefix, retainDefs, *lists): copying = 1 listid = 0 output = [] for line in input.split("\n"): isStartGenerated = line.startswith(commentPrefix + "++Autogenerated") if copying and not isStartGenerated: output.append(line) if isStartGenerated: if retainDefs: output.append(line) copyin... |
def RegenerateOverLists(inpath, outpath, commentPrefix, crlf, *lists): | def Generate(inpath, outpath, commentPrefix, eolType, *lists): """Generate 'outpath' from 'inpath'. "eolType" indicates the type of EOLs to use in the generated file. It should be one of following constants: LF, CRLF, CR, or NATIVE. """ | def UpdateFile(filename, updated): """ If the file is different to updated then copy updated into the file else leave alone so CVS and make don't treat it as modified. """ try: infile = open(filename, "rb") except IOError: # File is not there yet out = open(filename, "wb") out.write(updated) out.close() print "New", fi... |
infile = open(inpath, "rb") | infile = open(inpath, "r") | def RegenerateOverLists(inpath, outpath, commentPrefix, crlf, *lists): try: infile = open(inpath, "rb") except IOError: print "Can not open", inpath return original = infile.read() infile.close() contents = original.replace("\r\n", "\n") updated = CopyWithInsertion(contents, commentPrefix, inpath == outpath, *lists) if... |
contents = original.replace("\r\n", "\n") updated = CopyWithInsertion(contents, commentPrefix, inpath == outpath, *lists) if crlf: updated = updated.replace("\n", "\r\n") | updated = CopyWithInsertion(original, commentPrefix, inpath == outpath, eolType, *lists) | def RegenerateOverLists(inpath, outpath, commentPrefix, crlf, *lists): try: infile = open(inpath, "rb") except IOError: print "Can not open", inpath return original = infile.read() infile.close() contents = original.replace("\r\n", "\n") updated = CopyWithInsertion(contents, commentPrefix, inpath == outpath, *lists) if... |
def Regenerate(filename, commentPrefix, *lists): RegenerateOverLists(filename, filename, commentPrefix, 1, *lists) def RegenerateBinary(filename, commentPrefix, *lists): RegenerateOverLists(filename, filename, commentPrefix, 0, *lists) def Generate(inpath, outpath, commentPrefix, *lists): RegenerateOverLists(inpath, ... | def Regenerate(filename, commentPrefix, eolType, *lists): """Regenerate the given file. "eolType" indicates the type of EOLs to use in the generated file. It should be one of following constants: LF, CRLF, CR, or NATIVE. """ Generate(filename, filename, commentPrefix, eolType, *lists) | def Regenerate(filename, commentPrefix, *lists): RegenerateOverLists(filename, filename, commentPrefix, 1, *lists) |
def foolish( self ): import pdb; pdb.set_trace() return None _p_jar = property( lambda self: None, foolish ) | def foolish( self ): import pdb; pdb.set_trace() return None | |
from sqlalchemy.attributes import AttributeManager | def managed_attributes(self, class_): """returns an iterator of all InstrumentedAttribute objects associated with the given class.""" if not isinstance(class_, type): raise repr(class_) + " is not a type" for key in dir(class_): value = getattr(class_, key, None) if isinstance(value, InstrumentedAttribute): yield value... | |
for column in table.columns: d[ column.name ] = visitor.visit( column ) | d[ column.name ] = visitor.visit( column ) if 'properties' in kw: for name, iface_schema in kw['properties'].items(): d[ name ] = schema.Object( iface_schema, required=False ) | def translate( self, table, annotation, __module__, **kw): |
return -1 | return 0 | def importmodel(filename): try: f = open(filename, "r") except IOError: print "ERROR opening file" return -1 print "\t Sorry the roundabout plugin loader isn't here yet" f.close() return -1 |
def delaunayMap(face, size, performCleaning = True): | def delaunayMap(face, size, performCleaning = True, simplifyEpsilon = None): | def delaunayMap(face, size, performCleaning = True): "USAGE: dlm = delaunayMap(polygon, mapSize)" c = face.contours() jumpPoints = [0] points = contourPoly(c[0]) del points[-1] jumpPoints.append(len(points)) for anchor in c[1:]: points.extend(contourPoly(anchor)) del points[-1] jumpPoints.append(len(points)) print "-... |
points.extend(contourPoly(anchor)) | innerContour = contourPoly(anchor) if simplifyEpsilon != None: innerContour = simplifyPolygon( innerContour, simplifyEpsilon, simplifyEpsilon) points.extend(innerContour) | def delaunayMap(face, size, performCleaning = True): "USAGE: dlm = delaunayMap(polygon, mapSize)" c = face.contours() jumpPoints = [0] points = contourPoly(c[0]) del points[-1] jumpPoints.append(len(points)) for anchor in c[1:]: points.extend(contourPoly(anchor)) del points[-1] jumpPoints.append(len(points)) print "-... |
print "- reducing delaunay triangulation to inner part", | def delaunayMap(face, size, performCleaning = True): "USAGE: dlm = delaunayMap(polygon, mapSize)" c = face.contours() jumpPoints = [0] points = contourPoly(c[0]) del points[-1] jumpPoints.append(len(points)) for anchor in c[1:]: points.extend(contourPoly(anchor)) del points[-1] jumpPoints.append(len(points)) print "-... | |
sys.stderr.write(".") | sys.stdout.write(".") | def cleanOuter(map): for edge in map.edgeIter(): if edge.isContourEdge: dart = map.dart(edge.isContourEdge) assert dart.edgeLabel() == edge.label(), str(edge) while True: mergeDart = dart.clone().prevSigma() if mergeDart.edge().isContourEdge: break mergeFaces(mergeDart).isOutside = True sys.stderr.write(".") qt.qApp.p... |
nodePositions.append((dart1[0]+dart2[0]+dart3[0])/3) | nodePos = (dart1[0]+dart2[0]+dart3[0])/3 if triangle.type == "J": a = (dart2[0]-dart1[0]).magnitude() b = (dart3[0]-dart2[0]).magnitude() c = (dart1[0]-dart3[0]).magnitude() sv = Vector(a, b, c) sv /= sv.magnitude() if dot(sv, Vector(1, 1, 1)) < 1.6: s = [a,b,c] s.sort() if s[2] == a: nodePos = (dart2[0]+dart1[0])/2 el... | def catMap(delaunayMap): """Extract a CAT (chordal axis transform) from a Map object containing a Delaunay Triangulation. Assumes that all edges have only two points and that all finite regions are triangles (such a Map is returned by delaunayMap()).""" nodePositions = [None] sigmaOrbits = [None] originalDarts = [None... |
print "scanPoly tested OK." | print "basic scanPoly tested OK." from operator import setitem def distinct(l): d = {} map(setitem, (d,)*len(l), l, []) return d.keys() def points(scanlines): result = [] for i, scanline in enumerate(scanlines): for segment in scanline: for x in range(segment.begin, segment.end): result.append((x, i+scanlines.start... | def scanPoly2List(*args): return [[(e.begin, e.direction, e.end) for e in list(s)] for s in scanPoly(*args)] |
map = Map(maxima, [fl and fl[0] or None for fl in flowlines], Size2D(256, 256)) class FaceLookup: def __init__(self, map): self._map = map self.errorCount = 0 self.errorLabels = [] def __call__(self, faceLabel): if faceLabel < 0: return faceLabel = int(faceLabel) try: assert self._map.face(faceLabel) != None except: ... | map = Map(maxima, [fl and fl[0] for fl in flowlines], Size2D(256, 256)) | def scanPoly2List(*args): return [[(e.begin, e.direction, e.end) for e in list(s)] for s in scanPoly(*args)] |
assert checkConsistency(map) checkLabelConsistency(map) | assert checkConsistency(map), "map inconsistent" assert checkLabelConsistency(map), "map.labelImage inconsistent" def checkPolygons(map): clean = True for edge in map.edgeIter(): l, pa = edge.length(), edge.partialArea() p = Polygon(edge) p.invalidateProperties() if abs(l - p.length()) > 1e-6: print "edge %d: length... | def checkLabelConsistency(map): #print "checkLabelConsistency skipped (segfaults)." #return fl = FaceLookup(map) inspectImage(map.labelImage, fl) if fl.errorCount: sys.stderr.write("labelImage contains %d pixels with unknown faces!\n" % ( fl.errorCount, )) sys.stderr.write(" unknown face labels found: %s\n" % (fl.erro... |
points = [Vector2(*p)+offset for p in iter(edge.start)] | points = [(Vector2(*p)+offset) * scale for p in iter(edge.start)] | def pixelMapData(geomap, offset, scale): nodes = [None] * geomap.maxNodeLabel() for node in geomap.nodes: ul = node.bounds.upperLeft() center = Vector2(*ul) + Vector2(node.bounds.width() - 1, node.bounds.height() - 1) / 2 nodes[node.label] = (center+offset) * scale edges = [None] * geomap.maxEdgeLabel() for edge in ge... |
startNodeLabel, endNodeLabel, Polygon(points) * scale) | startNodeLabel, endNodeLabel, Polygon(points)) | def pixelMapData(geomap, offset, scale): nodes = [None] * geomap.maxNodeLabel() for node in geomap.nodes: ul = node.bounds.upperLeft() center = Vector2(*ul) + Vector2(node.bounds.width() - 1, node.bounds.height() - 1) / 2 nodes[node.label] = (center+offset) * scale edges = [None] * geomap.maxEdgeLabel() for edge in ge... |
def pixelMap2subPixelMap(geomap, scale = 1.0, offset = Vector2(0, 0)): | def pixelMap2subPixelMap(geomap, scale = 1.0, offset = Vector2(0, 0), labelImageSize = None): | def pixelMap2subPixelMap(geomap, scale = 1.0, offset = Vector2(0, 0)): nodes, edges = pixelMapData(geomap, offset, scale) return Map(nodes, edges, geomap.cellImage.size() * scale) |
return Map(nodes, edges, geomap.cellImage.size() * scale) | if labelImageSize == None: labelImageSize = geomap.cellImage.size() * scale return Map(nodes, edges, labelImageSize) | def pixelMap2subPixelMap(geomap, scale = 1.0, offset = Vector2(0, 0)): nodes, edges = pixelMapData(geomap, offset, scale) return Map(nodes, edges, geomap.cellImage.size() * scale) |
crackEdges = True | def pixelMap2subPixelMap(geomap, scale = 1.0, offset = Vector2(0, 0)): nodes, edges = pixelMapData(geomap, offset, scale) return Map(nodes, edges, geomap.cellImage.size() * scale) | |
lab, count = watershedSegmentation(e.img.bi.gm, KeepContours) | if crackEdges: lab, count = watershedUnionFind8(e.img.bi.gm) ce = regionImageToCrackEdgeImage(lab, 0) else: lab, count = watershedSegmentation(e.img.bi.gm, KeepContours) | def pixelMap2subPixelMap(geomap, scale = 1.0, offset = Vector2(0, 0)): nodes, edges = pixelMapData(geomap, offset, scale) return Map(nodes, edges, geomap.cellImage.size() * scale) |
geomap = GeoMap(lab, 0, CellType.Vertex) | if crackEdges: geomap = GeoMap(ce, 0, CellType.Line) else: geomap = GeoMap(lab, 0, CellType.Vertex) | def pixelMap2subPixelMap(geomap, scale = 1.0, offset = Vector2(0, 0)): nodes, edges = pixelMapData(geomap, offset, scale) return Map(nodes, edges, geomap.cellImage.size() * scale) |
spmap = pixelMap2subPixelMap(geomap) | if crackEdges: spmap = pixelMap2subPixelMap( geomap, 0.5, labelImageSize = (geomap.cellImage.size()-Size2D(3,3))/2) else: spmap = pixelMap2subPixelMap(geomap) | def pixelMap2subPixelMap(geomap, scale = 1.0, offset = Vector2(0, 0)): nodes, edges = pixelMapData(geomap, offset, scale) return Map(nodes, edges, geomap.cellImage.size() * scale) |
penColor = edgeOverlay.color if type(penColor) == qt.QColor: penColor = qtColor2figColor(penColor) | if not attr.has_key("penColor"): penColor = edgeOverlay.color if type(penColor) == qt.QColor: penColor = qtColor2figColor(penColor) attr["penColor"] = penColor | def addEdgeOverlay(self, edgeOverlay, **attr): """Adds and returns fig.Polygon for all edges (or -parts, see addClippedPoly) of the given overlay, using the overlays' color.""" |
def delaunayMap(face, size, performCleaning = True, simplifyEpsilon = None): "USAGE: dlm = delaunayMap(polygon, mapSize)" c = face.contours() jumpPoints = [0] points = contourPoly(c[0]) if simplifyEpsilon != None: points = simplifyPolygon(points, simplifyEpsilon, simplifyEpsilon) del points[-1] jumpPoints.append(len(p... | def delaunayMap(face, size, simplifyEpsilon = None, markContour = True, performCleaning = True): """USAGE: dlm = delaunayMap(face, mapSize) `face` should be a Map.Face object, and all its contours will be extracted. (If a list of points or a Polygon is passed as `face`, it is assumed to contain exactly one contour.) ... | def delaunayMap(face, size, performCleaning = True, simplifyEpsilon = None): "USAGE: dlm = delaunayMap(polygon, mapSize)" c = face.contours() jumpPoints = [0] points = contourPoly(c[0]) if simplifyEpsilon != None: points = simplifyPolygon(points, simplifyEpsilon, simplifyEpsilon) del points[-1] jumpPoints.append(len(p... |
innerContour = simplifyPolygon( innerContour, simplifyEpsilon, simplifyEpsilon) points.extend(innerContour) | points = simplifyPolygon(points, simplifyEpsilon, simplifyEpsilon) | def delaunayMap(face, size, performCleaning = True, simplifyEpsilon = None): "USAGE: dlm = delaunayMap(polygon, mapSize)" c = face.contours() jumpPoints = [0] points = contourPoly(c[0]) if simplifyEpsilon != None: points = simplifyPolygon(points, simplifyEpsilon, simplifyEpsilon) del points[-1] jumpPoints.append(len(p... |
edge.isBarb = edge.startNode().degree() == 1 or \ edge.endNode().degree() == 1 and \ | edge.isBarb = (edge.startNode().degree() == 1 or \ edge.endNode().degree() == 1) and \ | def pruneBarbsByLength(skel, minLength): for edge in skel.edgeIter(): edge.isBarb = edge.startNode().degree() == 1 or \ edge.endNode().degree() == 1 and \ edge.length() < minLength return _pruneBarbsInternal(skel) |
if (dart[0] - p).magnitude() < maxDist or \ (dart[-1] - p).magnitude() < maxDist: | if (dart[0] - p).magnitude() < maxDist: | def pruneBarbsByDist(skel, maxDist): for edge in skel.edgeIter(): edge.isBarb = False for node in skel.nodeIter(): if node.degree() != 1: continue p = node.position() dart = node.anchor() while True: if (dart[0] - p).magnitude() < maxDist or \ (dart[-1] - p).magnitude() < maxDist: dart.edge().isBarb = True if dart.n... |
return _pruneBarbsInternal(skel) | result = _pruneBarbsInternal(skel) shortenLength = maxCutLength * 2 / 3 for edge in skel.edgeIter(): edge.isBarb = False if hasattr(edge, "barbNodeLabel"): print "shortening", edge barbNodeLabel, endPos = edge.barbNodeLabel if barbNodeLabel == edge.startNodeLabel(): i = leaveCircle(edge, 1, endPos, shortenLength) i... | def pruneBarbsByDist(skel, maxDist): for edge in skel.edgeIter(): edge.isBarb = False for node in skel.nodeIter(): if node.degree() != 1: continue p = node.position() dart = node.anchor() while True: if (dart[0] - p).magnitude() < maxDist or \ (dart[-1] - p).magnitude() < maxDist: dart.edge().isBarb = True if dart.n... |
attrTrans = string.maketrans(".+-", "__n") | def postMergeEdges(self, survivor): survivor._passValue = self.mergedPV survivor._saddles = self.mergedSaddles | |
self.attrName = attrName.translate(self.attrTrans) | self.attrName = _makeAttrName(attrName) | def __init__(self, map, attrName): DynamicEdgeStatistics.__init__(self, map) self.attrName = attrName.translate(self.attrTrans) |
self.attrName="minDist_"+bi.name self.attrName=self.attrName.translate(string.maketrans(".+-", "__n")) | self.attrName = _makeAttrName("minDist_"+bi.name) | def __init__(self, map, bi): DynamicEdgeStatistics.__init__(self, map) self.attrName="minDist_"+bi.name self.attrName=self.attrName.translate(string.maketrans(".+-", "__n")) minimaMap = PositionedMap() minima=localMinmax(bi.gm,True,False,False) for y in range(minima.height()): for x in range(minima.width()): if minima[... |
attrName="phase_%s" % (s) attrName=attrName.translate(string.maketrans(".+-", "__n")) | attrName = _makeAttrName("phase_%s" % (s)) | def __init__(self, map, image, scaleList, splineOrder): DynamicEdgeStatistics.__init__(self, map) self.scaleList=scaleList self.attrNames=[] for s in scaleList: attrName="phase_%s" % (s) attrName=attrName.translate(string.maketrans(".+-", "__n")) self.attrNames.append(attrName) phaseImages=[calcBTPhaseImage(image,scale... |
self.attrName="contAngle_%s" % (self.length) self.attrName=self.attrName.translate(string.maketrans(".+-", "__n")) | self.attrName = _makeAttrName("contAngle_%s" % (self.length)) | def __init__(self, map, length): self.map = ref(map) # for detachHooks() self.length=length self.attrName="contAngle_%s" % (self.length) self.attrName=self.attrName.translate(string.maketrans(".+-", "__n")) for edge in map.edgeIter(): self.calcContAngle(edge) map.postMergeEdgesHooks.append(self.postMergeEdges) |
def __init__(self, map, dx, skip): self.dx=dx self.skip=skip self.attrName="curvChange_%s_%s" % (self.dx,self.skip) self.attrName=self.attrName.translate(string.maketrans(".+-", "__n")) | def __init__(self, map): | def __init__(self, map, dx, skip): self.dx=dx self.skip=skip self.attrName="curvChange_%s_%s" % (self.dx,self.skip) self.attrName=self.attrName.translate(string.maketrans(".+-", "__n")) for edge in map.edgeIter(): self.calcCurvChange(edge) map.postMergeEdgesHooks.append(self.postMergeEdges) self.map = ref(map) # for de... |
def calcCurvChange(self,edge): stats = EdgeStatistics() try: l=curvatureList(edge,self.dx,self.skip) except: l=[] if len(l)>1: for i in range(len(l)-1): segment = l[i+1][0] - l[i][0] stats(-math.log((abs(l[i+1][1]-l[i][1])/segment)+1),segment) else: stats(0,1) setattr(edge, self.attrName, stats) | def calcCurvChange(self, edge): edge.curvChange = fitLine(edge.tangents)[2] | def calcCurvChange(self,edge): stats = EdgeStatistics() try: l=curvatureList(edge,self.dx,self.skip) except: l=[] if len(l)>1: for i in range(len(l)-1): segment = l[i+1][0] - l[i][0] stats(-math.log((abs(l[i+1][1]-l[i][1])/segment)+1),segment) else: stats(0,1) setattr(edge, self.attrName, stats) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.