rem
stringlengths
0
322k
add
stringlengths
0
2.05M
context
stringlengths
8
228k
ordered_args[i] = v
def do_POST(self): status = 500 try: if self.server.config.dumpHeadersIn: s = 'Incoming HTTP headers' debugHeader(s) print self.raw_requestline.strip() print "\n".join(map (lambda x: x.strip(), self.headers.headers)) debugFooter(s)
if e[0] < 0: neg = '-' e[0] = abs(e[0])
def _marshalData(self): if self._cache == None: d = self._data e = list(d) neg = ''
elif e[0] < 100: e[0] = '-' + "%02d" % e[0]
def _marshalData(self): if self._cache == None: d = self._data e = list(d) neg = ''
e[0] = "%04d" % e[0]
if e[0] < 0: neg = '-' e[0] = abs(e[0]) if e[0] < 100: e[0] = '-' + "%02d" % e[0] else: e[0] = "%04d" % e[0]
def _marshalData(self): if self._cache == None: d = self._data e = list(d) neg = ''
print 'subtype'
def extractSubtypes(self): subTypes = ''
self.__ma = ma self.__config = config self.__action = 0
self.__ma = ma self.__config = config return def __call__(self, *args, **kw):
def __init__(self, call, name, ns = None, sa = None, hd = None, ma = None, config = Config):
self.__action = 1
return self.__repr__()
def __init__(self, call, name, ns = None, sa = None, hd = None, ma = None, config = Config):
self.__action = 2 else: self._action = 3 def __call__(self, *args, **kw): if self.__action == 1: return self.__repr__() elif self.__action == 2: return self.__f_call(*args, **kw)
return self.__f_call(*args, **kw)
def __init__(self, call, name, ns = None, sa = None, hd = None, ma = None, config = Config):
pyobj.Actor = sub = GTD('urn:test', 'IfElseActor')(None).pyclass() klass = 'myclass' name = 'whatever' sub.Gui = 'foo' sub.Parameter = 'bar' sub.set_attribute_class(klass) sub.set_attribute_name(name)
ps = ParsedSoap(MSG) pyobj0 = ps.Parse(pyobj.typecode) sub0 = pyobj0.Actor self.failUnless(sub0.get_attribute_class() == klass, 'bad attribute class') self.failUnless(sub0.get_attribute_name() == name, 'bad attribute name') pyobj.Actor = sub1 = GTD('urn:test', 'IfElseActor')(None).pyclass() sub1.Gui = 'foo' sub1.Par...
def test_local_type_substitution(self): self.types_module pyobj = GED('urn:test', 'test').pyclass() # derived type pyobj.Actor = sub = GTD('urn:test', 'IfElseActor')(None).pyclass() klass = 'myclass' name = 'whatever'
print xml
def test_local_type_substitution(self): self.types_module pyobj = GED('urn:test', 'test').pyclass() # derived type pyobj.Actor = sub = GTD('urn:test', 'IfElseActor')(None).pyclass() klass = 'myclass' name = 'whatever'
self.failUnless(sub.get_attribute_class() == klass, 'bad attribute class') self.failUnless(sub.get_attribute_name() == name, 'bad attribute name')
self.failUnless(sub2.get_attribute_class() == klass, 'bad attribute class') self.failUnless(sub2.get_attribute_name() == name, 'bad attribute name')
def test_local_type_substitution(self): self.types_module pyobj = GED('urn:test', 'test').pyclass() # derived type pyobj.Actor = sub = GTD('urn:test', 'IfElseActor')(None).pyclass() klass = 'myclass' name = 'whatever'
self.failUnless(isinstance(sub2.typecode, sub.typecode.__class__),
self.failUnless(isinstance(sub2.typecode, sub1.typecode.__class__),
def test_local_type_substitution(self): self.types_module pyobj = GED('urn:test', 'test').pyclass() # derived type pyobj.Actor = sub = GTD('urn:test', 'IfElseActor')(None).pyclass() klass = 'myclass' name = 'whatever'
(sub2.typecode, sub.typecode.__class__))
(sub2.typecode, sub1.typecode.__class__))
def test_local_type_substitution(self): self.types_module pyobj = GED('urn:test', 'test').pyclass() # derived type pyobj.Actor = sub = GTD('urn:test', 'IfElseActor')(None).pyclass() klass = 'myclass' name = 'whatever'
t._dec.attributes['nillable'] = u"true"
if hasattr(t, '_ref'): t._ref.attributes['nillable'] = u"true" else: t._dec.attributes['nillable'] = u"true"
def getModelGroup(self): """returns a model group adapter """
self.cb(sw, pyobj)
self.cb(sw, pyobj, unsuppressedPrefixes)
def serialize(self, sw, pyobj, name=None, attrtext='',
sw.AddCallback(self.cb, pyobj) def cb(self, sw, pyobj):
sw.AddCallback(self.cb, pyobj, unsuppressedPrefixes) def cb(self, sw, pyobj, unsuppressedPrefixes=[]):
def serialize(self, sw, pyobj, name=None, attrtext='',
Canonicalize(pyobj, sw, comments=self.comments)
Canonicalize(pyobj, sw, unsuppressedPrefixes=unsuppressedPrefixes, comments=self.comments)
def cb(self, sw, pyobj): if sw.Known(pyobj): return objid = '%x' % id(pyobj) n = self.pname or ('E' + objid) print >>sw, '<%s SOAP-ENC:encodingStyle="" id="%s">' % (n, objid) Canonicalize(pyobj, sw, comments=self.comments) print >>sw, '</%s>' % n
parser.parse(inpsrc)
try: parser.parse(inpsrc) except xml.sax.SAXParseException: parser._parser = None
def _parseSOAP(xml_str, rules = None): try: from cStringIO import StringIO except ImportError: from StringIO import StringIO parser = xml.sax.make_parser() t = SOAPParser(rules = rules) parser.setContentHandler(t) e = xml.sax.handler.ErrorHandler() parser.setErrorHandler(e) inpsrc = xml.sax.xmlreader.InputSource() in...
def __init__(self, errno): self.errno = errno def __str__(self): if self.errno == ERR_GENERIC: return "Any ACPI error occured." elif self.errno == ERR_NO_DEVICE: return "ACPI is not configured on this host." elif self.errno == ERR_NOT_IMPLEMENTED: return "No implementation for this operating system." elif self.errno =...
self.update() def percent(self): return self.life_percent def time(self): return self.life_time def charging_state(self): return self.ac_line_state
def __init__(self, errno): self.errno = errno
class PmuLinux(PmuBase): def update(self):
def __str__(self): if self.errno == ERR_GENERIC: return "Any ACPI error occured." elif self.errno == ERR_NO_DEVICE: return "ACPI is not configured on this host." elif self.errno == ERR_NOT_IMPLEMENTED: return "No implementation for this operating system." elif self.errno == ERR_NO_LOW_LEVEL: return "Acpi_lowlevel modul...
class Acpi: """Interface class for ACPI"""
try: pmu_proc = open("/proc/pmu/info") except IOError: raise EnvironmentError data = {} lines = pmu_proc.readlines() for line in lines: token = line.split(':') data[token[0].strip()] = token[1].strip() try: pmu_battery = open("/proc/pmu/battery_0") except: self.ac_line_state = ONLINE return lines = pmu_battery.readl...
def __str__(self): if self.errno == ERR_GENERIC: return "Any ACPI error occured." elif self.errno == ERR_NO_DEVICE: return "ACPI is not configured on this host." elif self.errno == ERR_NOT_IMPLEMENTED: return "No implementation for this operating system." elif self.errno == ERR_NO_LOW_LEVEL: return "Acpi_lowlevel modul...
def __init__(self): res = sys.platform if res.find("freebsd4") > -1: self.acpi = None raise NotImplemented elif res.find("netbsd1") > -1: self.acpi = None raise NotImplemented elif res.find("linux2") > -1: self.acpi = AcpiLinux() elif res.find("linux") > -1: self.acpi = AcpiLinux() else: self.acpi = None raise No...
self.life_time = int(int(data['time rem.']) / 60)
def __init__(self): res = sys.platform if res.find("freebsd4") > -1: self.acpi = None #throw exception raise NotImplemented
def frequency(self, idx): """ Return the frequency of the processor""" return self.acpi.frequency(idx) def performance_states(self, idx): """ Return a list of available frequencies for the proc """ return self.acpi.performance_states(idx) def set_frequency(self, f): """ Set the processor frequency - Warning ! Needs ...
pmu_proc.close() pmu_battery.close()
def fan_state(self, idx): """Returns fan states""" return self.acpi.fan_state(idx)
if design_capacity == 0:
last_full_capacity = last_full_capacity + self.last_full_capacity[i] current_capacity = max(design_capacity, last_full_capacity) if current_capacity == 0:
def percent(self): """Returns percentage capacity of all batteries"""
return (life_capacity * 100) / design_capacity
return (life_capacity * 100) / current_capacity
def percent(self): """Returns percentage capacity of all batteries"""
time = totalCapacity / totalRate
if totalRate: time = totalCapacity / totalRate else: time = totalCapacity
def estimated_lifetime(self): # what should we return if state==charging? # it's not clean to return a time in one case and any # English string in another case. # The user can check for ac-state before call this func # fixed bug - if a battery is full and not discharging, it # would not be counted in the estimated li...
pb = self.images[(percent/10)]
index = min(percent/10+1, 10) pb = self.images[index]
def update_display(self, BATTERY): """Updates all the parts of our applet, and cleans it up if needed.""" BATTERY.update() percent = BATTERY.percent()
unittest.main()
import sys sys.path.append('..') unittest.main()
def testDoImport(self): self.importer.doImport()
def manage_addZSQLMethod(self, id, title,
def manage_addZSQLMethod(id, title,
def manage_addZSQLMethod(self, id, title, connection_id, arguments, template): """ Add an SQL Method to an ObjectManager. The 'connection_id' argument is the id of a database connection that resides in the current folder or in a folder above the current folder. The database should understand SQL. The 'arguments' ar...
They support three important abstractions:
SQL Methods behave like methods of the folders they are accessed in. In particular, they can be used from other methods, like Documents, ExternalMethods, and even other SQL Methods.
def manage_addZSQLMethod(self, id, title, connection_id, arguments, template): """ Add an SQL Method to an ObjectManager. The 'connection_id' argument is the id of a database connection that resides in the current folder or in a folder above the current folder. The database should understand SQL. The 'arguments' ar...
- Method
Database methods support the Searchable Object Interface. Search interface wizards can be used to build user interfaces to them. They can be used in joins and unions. They provide meta-data about their input parameters and result data.
def manage_addZSQLMethod(self, id, title, connection_id, arguments, template): """ Add an SQL Method to an ObjectManager. The 'connection_id' argument is the id of a database connection that resides in the current folder or in a folder above the current folder. The database should understand SQL. The 'arguments' ar...
SQL Methods behave like methods of the folders they are accessed in. In particular, they can be used from other methods, like Documents, ExternalMethods, and even other SQL Methods.
For more information, see the searchable-object interface specification.
def manage_addZSQLMethod(self, id, title, connection_id, arguments, template): """ Add an SQL Method to an ObjectManager. The 'connection_id' argument is the id of a database connection that resides in the current folder or in a folder above the current folder. The database should understand SQL. The 'arguments' ar...
- Searchability
Database methods support URL traversal to access and invoke methods on individual record objects. For example, suppose you had an 'employees' database method that took a single argument 'employee_id'. Suppose that employees had a 'service_record' method (defined in a record class or acquired from a folder). The 'servi...
def manage_addZSQLMethod(self, id, title, connection_id, arguments, template): """ Add an SQL Method to an ObjectManager. The 'connection_id' argument is the id of a database connection that resides in the current folder or in a folder above the current folder. The database should understand SQL. The 'arguments' ar...
Database methods support the Searchable Object Interface. Search interface wizards can be used to build user interfaces to them. They can be used in joins and unions. They provide meta-data about their input parameters and result data.
employees/employee_id/1234/service_record
def manage_addZSQLMethod(self, id, title, connection_id, arguments, template): """ Add an SQL Method to an ObjectManager. The 'connection_id' argument is the id of a database connection that resides in the current folder or in a folder above the current folder. The database should understand SQL. The 'arguments' ar...
For more information, see the searchable-object interface specification. - Containment Database methods support URL traversal to access and invoke methods on individual record objects. For example, suppose you had an 'employees' database method that took a single argument 'employee_id'. Suppose that employees had a ...
Search results are returned as Record objects. The schema of a Record objects matches the schema of the table queried in the search.
def manage_addZSQLMethod(self, id, title, connection_id, arguments, template): """ Add an SQL Method to an ObjectManager. The 'connection_id' argument is the id of a database connection that resides in the current folder or in a folder above the current folder. The database should understand SQL. The 'arguments' ar...
def __call__(self, REQUEST=None, **kw):
def __call__(REQUEST=None, **kw):
def __call__(self, REQUEST=None, **kw): """
def manage_edit(self,title,connection_id,arguments,template):
def manage_edit(title,connection_id,arguments,template):
def manage_edit(self,title,connection_id,arguments,template): """
specification, as would be given in the SQL method cration
specification, as would be given in the SQL method creation
def manage_edit(self,title,connection_id,arguments,template): """
if q.has_key('atbibliotopic_sort_on'):
if sequence_sort_on:
def queryCatalog(self, REQUEST=None, batch=False, b_size=None, full_objects=False, **kw): """Invoke the catalog using our criteria to augment any passed in query before calling the catalog. """ if REQUEST is None: REQUEST = getattr(self, 'REQUEST', {}) b_start = REQUEST.get('b_start', 0)
if q.has_key('atbibliotopic_sort_on'): sequence_sort_on = q['atbibliotopic_sort_on'] del q['atbibliotopic_sort_on']
def queryCatalog(self, REQUEST=None, batch=False, b_size=None, full_objects=False, **kw): """Invoke the catalog using our criteria to augment any passed in query before calling the catalog. """ if REQUEST is None: REQUEST = getattr(self, 'REQUEST', {}) b_start = REQUEST.get('b_start', 0)
if navtool.getProperty('enable_wf_state_filtering', False):
if query and navtool.getProperty('enable_wf_state_filtering', False):
def buildQuery(self, **kw): """Build Query """
security.declareProtected(permissions.View, 'filterWfStateIfNotOwner')
security.declareProtected(permissions.View, 'filterWfStateIfNotOwnerOfReference')
def criteriaByIndexId(self, indexId): # do not change the order of BIBLIOTOPIC_SORTFIELDS + BIBLIOTOPIC_CRITERIAFIELDS
print CATALOG_INDEXES
def addIndexesToCatalogTool(self, out): ctool = getToolByName(self, 'portal_catalog') if ctool: # add indexes and metadatas to the portal catalog ct = getToolByName(self, 'portal_catalog') print CATALOG_INDEXES for idx in CATALOG_INDEXES: if idx['name'] in ct.indexes(): ct.delIndex(idx['name']) ct.addIndex(**idx) ct.re...
if file.endswith(ext): return file[:-1*ext.__len__()] else: return file
end=file.__len__() try: end=file.rindex(ext) except ValueError: pass return file[begin:end]
def get_root_name(file): """Determine the root of the filename assuming that it either ends with '.xml' or is already a root""" ext=".xml" if file.endswith(ext): return file[:-1*ext.__len__()] else: return file
outfile="%s.%s" % (root_name,ext)
outfile="%s%s.%s" % (path,root_name,ext)
def process_file(infile, outfile, options, DEBUG=1): # parse the xml file if DEBUG: print "Processing \"%s\"" % infile doc=parse(infile) if DEBUG: print " ... done" # determine the input name try: root_name=options.pop("--root") except KeyError: root_name=get_root_name(infile) # determine the proper formatte...
template="/home/hgilde/nexus/nexus/contrib/bindings/nxpylib/test/monoxtas_template.xml")
template="monoxtas_template.xml")
def main(args): """ the entry point for testing purposes """ print "EXAMPLE 0: LOAD TEMPLATE META-DTD AND GENERATE SKELETON MONOXTAS NXFILE" print "========================================================================" f = NXfile(filename="monoxtas_template.nxs", mode=NXACC_CREATE5, template="/home/hgilde/nexus/...
class NodeLocation(testcase.TestCase): jsClass = u'Nevow.Athena.Tests.NodeLocation' def getWidgetDocument(self): """ Return some child elements for us to search in.
def getDynamicWidget(self): """ Return a widget dynamically for us to have more fun with.
def bar(self, req, tag): e = NodeLocationSubElement2() e.setFragmentParent(self) return e
w(obj.replace('\\', '\\\\').replace('"', '\\"').encode('unicode-escape'))
w(unicodeEscape(obj))
def _serialize(obj, w, seen): if isinstance(obj, types.BooleanType): if obj: w('true') else: w('false') elif isinstance(obj, (int, long, float)): w(str(obj)) elif isinstance(obj, unicode): w('"') w(obj.replace('\\', '\\\\').replace('"', '\\"').encode('unicode-escape')) w('"') elif isinstance(obj, types.NoneType): w('nu...
self.assertEquals(self.transport, [[(0, athena.CLOSE)], [(0, athena.CLOSE)]])
self.assertEquals(self.transport, [[(0, (athena.CLOSE, []))], [(0, (athena.CLOSE, []))]])
def testClosing(self): """ Test that closing a reliable message deliverer causes all of outs remaining outputs to be used up with a close message and that any future outputs added to it are immediately used in a similar manner. """ self.rdm.addOutput(mappend(self.transport)) self.rdm.addOutput(mappend(self.transport)) ...
self.assertEquals(self.transport, [[(0, athena.CLOSE)]])
self.assertEquals(self.transport, [[(0, (athena.CLOSE, []))]])
def testClosing(self): """ Test that closing a reliable message deliverer causes all of outs remaining outputs to be used up with a close message and that any future outputs added to it are immediately used in a similar manner. """ self.rdm.addOutput(mappend(self.transport)) self.rdm.addOutput(mappend(self.transport)) ...
self.livePage._disconnected()
self.livePage._disconnected(error.ConnectionDone("Connection closed"))
def action_close(self, ctx): """ The client is going away. Clean up after them. """ self.livePage._disconnected()
return self
return configurable.TypedInterfaceConfigurable(self)
def configurable_formBuilder(self, ctx): return self
return urlToChild(ctx, *segments[1:], **{'__session_just_started__':1}), ()
return urlToChild(ctx, *segments[1:]), ()
def locateChild(self, ctx, segments): request = inevow.IRequest(ctx) # ctx.remember(self, ILoginManager) path = segments[0] if self.useCookies: cookie = request.getCookie(self.cookieKey) else: cookie = '' request.setupSession = lambda : self.createSession(ctx, segments)
docFactory = loaders.stan(T.input(type="text", id="typehere", render=T.directive('liveFragment')))
docFactory = loaders.stan( T.span(render=T.directive('liveFragment'))[ '\n', T.input(type="text", _class="typehere"), '\n', T.h3(_class="description"), ])
def render_typehereField(self, ctx, data): frag = TypeAheadFieldFragment() frag.page = self return frag
def render_liveglue(self, ctx):
def render_liveglue(self, ctx, data):
def render_liveglue(self, ctx): if True: mk = tags.script(type='text/javascript', src=url.here.child("mochikit.js")) else: mk = [ tags.script(type='text/javascript', src=url.here.child('MochiKit').child(fName)) for fName in ['Base.js', 'Async.js']]
tags.script(type='text/javascript')[tags.raw(""" var nevow_livepageId = '%s'; """ % self.clientID)],
def render_liveglue(self, ctx): if True: mk = tags.script(type='text/javascript', src=url.here.child("mochikit.js")) else: mk = [ tags.script(type='text/javascript', src=url.here.child('MochiKit').child(fName)) for fName in ['Base.js', 'Async.js']]
d = {u'Divmod': util.resource_filename('nevow', 'athena.js'), u'Nevow.Athena': util.resource_filename('nevow', 'widget.js'), u'MochiKit': util.resource_filename('nevow', 'MochiKit.js')}
d = {}
def allJavascriptPackages(): """ Return a dictionary mapping JavaScript module names to local filenames which implement those modules. This mapping is constructed from all the C{IJavascriptPackage} plugins available on the system. It also includes C{Nevow.Athena} as a special case. """ d = {u'Divmod': util.resource_f...
self.mapping = {}
self.mapping = { u'Divmod': util.resource_filename('nevow', 'athena.js'), u'Nevow.Athena': util.resource_filename('nevow', 'widget.js'), u'MochiKit': util.resource_filename('nevow', 'MochiKit.js')}
def __init__(self, mapping=None): if mapping is None: self.mapping = {} self._loadPlugins = True else: self.mapping = mapping
class GetAttribute(testcase.TestCase): jsClass = u'Divmod.Runtime.Tests.GetAttribute'
def getWidgetDocument(self): """ Return part of a document which contains nodes nested several layers deep. The client side of this test will use their class names to determine that ordering of results from the DOM traversal function is correct. """ return tags.div(_class='container')[ tags.div(_class='left_child')[ t...
<div class="tabbedPane" xmlns:nevow="http://nevow.com/ns/nevow/0.1" nevow:render="liveFragment">
<div class="tabbedPane" xmlns:nevow="http://nevow.com/ns/nevow/0.1" nevow:render="liveFragment" style="opacity: .3">
def _(): for n, (tab, page) in enumerate(pages): tID = '%s_tab_%i'%(name, n) pID = '%s_page_%i'%(name, n) yield (t.li(id_=tID)[tab], t.div(id_=pID)[page], flt(js[tID,pID], quote = False))
"[v0.5] ", """Using a Page with a 'content' pattern is
"""[v0.5] Using a Page with a 'content' pattern is
def rend(self, context, data): # Create a new context so the current context is not polluted with # remembrances. context = WovenContext(parent=context)
self._disconnectNotifications = []
def _becomeLive(self): """ Assign this LivePage a clientID, associate it with a factory, and begin tracking its state. This only occurs when a LivePage is *rendered*, not when it is instantiated. """ self.clientID = self.factory.addClient(self)
d = {u'Nevow.Athena': util.resource_filename('nevow', 'widget.js')}
d = {u'Divmod': util.resource_filename('nevow', 'athena.js'), u'Nevow.Athena': util.resource_filename('nevow', 'widget.js'), u'MochiKit': util.resource_filename('nevow', 'MochiKit.js')}
def allJavascriptPackages(): """ Return a dictionary mapping JavaScript module names to local filenames which implement those modules. This mapping is constructed from all the C{IJavascriptPackage} plugins available on the system. It also includes C{Nevow.Athena} as a special case. """ d = {u'Nevow.Athena': util.reso...
if True: mk = tags.script(type='text/javascript', src=url.here.child("mochikit.js")) else: mk = [ tags.script(type='text/javascript', src=url.here.child('MochiKit').child(fName)) for fName in ['Base.js', 'Async.js']]
def render_liveglue(self, ctx, data): if True: mk = tags.script(type='text/javascript', src=url.here.child("mochikit.js")) else: mk = [ tags.script(type='text/javascript', src=url.here.child('MochiKit').child(fName)) for fName in ['Base.js', 'Async.js']]
mk, tags.script(type='text/javascript', src=url.here.child('MochiKitLogConsole.js')), tags.script(type='text/javascript', src=url.here.child("athena.js")),
tags.script(type='text/javascript', src=self.getJSModuleURL('MochiKit')), tags.script(type='text/javascript', src=self.getJSModuleURL('Divmod')),
def render_liveglue(self, ctx, data): if True: mk = tags.script(type='text/javascript', src=url.here.child("mochikit.js")) else: mk = [ tags.script(type='text/javascript', src=url.here.child('MochiKit').child(fName)) for fName in ['Base.js', 'Async.js']]
_javascript = {'mochikit.js': 'MochiKit.js', 'athena.js': 'athena.js', 'MochiKitLogConsole.js': 'MochiKitLogConsole.js'} def childFactory(self, ctx, name): if name in self._javascript: return static.File(util.resource_filename('nevow', self._javascript[name])) def child_MochiKit(self, ctx): return static.File(util.res...
def render_liveglue(self, ctx, data): if True: mk = tags.script(type='text/javascript', src=url.here.child("mochikit.js")) else: mk = [ tags.script(type='text/javascript', src=url.here.child('MochiKit').child(fName)) for fName in ['Base.js', 'Async.js']]
return self.page.jsModuleRoot.child(moduleName)
return self.page.getJSModuleURL(moduleName)
def getJSModuleURL(self, moduleName): return self.page.jsModuleRoot.child(moduleName)
args = req.args.get('args', [()])[0] if args != (): args = json.parse(args) kwargs = req.args.get('kw', [{}])[0] if kwargs != {}: kwargs = json.parse(kwargs)
args, kwargs = json.parse(req.content.read())
def renderHTTP(self, ctx): req = inevow.IRequest(ctx) try: d = self.livePage.addTransport(req) except defer.QueueOverflow: log.msg("Fast transport-close path") d = defer.succeed('') args = req.args.get('args', [()])[0] if args != (): args = json.parse(args) kwargs = req.args.get('kw', [{}])[0] if kwargs != {}: kwargs =...
self.deps = set(self._extractImports(file(jsFile, 'r')))
depgen = self._extractImports(file(jsFile, 'r')) self.deps = dict.fromkeys(depgen).keys()
def dependencies(self): jsFile = self.mapping[self.name] if jsFile is None: return iter(()) mtime = os.path.getmtime(jsFile) if mtime >= self.lastModified: self.deps = set(self._extractImports(file(jsFile, 'r'))) self.lastModified = mtime return self.deps
jsMod = jsMod.rsplit('.', 1)[0]
jsMod = '.'.join(jsMod.split('.')[:-1])
def getModuleForClass(self, className): if self._loadPlugins: self.mapping.update(allJavascriptPackages()) self._loadPlugins = False
modules = (dep.name for dep in self._getModuleForClass().allDependencies())
modules = [dep.name for dep in self._getModuleForClass().allDependencies()]
def render_liveFragment(self, ctx, data): modules = (dep.name for dep in self._getModuleForClass().allDependencies())
def qual(clazz): return clazz.__module__ + '.' + clazz.__name__
from twisted.python.reflect import qual, namedAny, allYourBase, accumulateBases from twisted.python.util import uniquify
def qual(clazz): return clazz.__module__ + '.' + clazz.__name__
def namedAny(name): """Get a fully named package, module, module-global object, or attribute. """ names = name.split('.') topLevelPackage = None moduleNames = names[:] while not topLevelPackage: try: trialname = '.'.join(moduleNames) topLevelPackage = __import__(trialname) except ImportError: import traceback i...
def namedAny(name): """Get a fully named package, module, module-global object, or attribute. """ names = name.split('.') topLevelPackage = None moduleNames = names[:] while not topLevelPackage: try: trialname = '.'.join(moduleNames) topLevelPackage = __import__(trialname) except ImportError: # if the ImportError happe...
if type(devname) is TupleType: docs[ele.sig_name.data] = (ele.alt_name.data, ele.description.data, []) for d in devname: docs[ele.sig_name.data][2].append(d) else: docs[ele.sig_name.data] = (ele.alt_name.data, ele.description.data, [devname])
try: if type(devname) is TupleType: docs[ele.sig_name.data] = (ele.alt_name.data, ele.description.data, []) for d in devname: docs[ele.sig_name.data][2].append(d) else: docs[ele.sig_name.data] = (ele.alt_name.data, ele.description.data, [devname]) except AttributeError: pass
def create_tabs (string): "Create a number of tabs according to the length of string" x = '' lim = (32 - len(string) + 7) / 8 if lim <= 0: lim = 1 for i in range(0, lim): x += "\t" return x
reg_info = ioreg_info_dict[name] reg_desc = reg_info.getElements ('DESCRIPTION')[0].getData ()
try: reg_info = ioreg_info_dict[name] try: reg_desc = reg_info.getElements ('DESCRIPTION')[0].getData () except IndexError: reg_desc = '' except KeyError: reg_info = None
def dump_ioregs (root): path = ['AVRPART', 'MEMORY', 'IO_MEMORY'] io_mem = root.getSubTree (path) ioregs = io_mem.getElements () ioreg_info_dict = gather_io_info (root) print ' <ioregisters>' # Skip the first 6 elements since they are just give start and stop # addresses. for ioreg in ioregs[6:]: name = ioreg.name...
bit_desc = bit_el.getElements ('DESCRIPTION')[0].getData () bit_access = bit_el.getElements ('ACCESS')[0].getData ()
try: bit_desc = bit_el.getElements ('DESCRIPTION')[0].getData () except IndexError: bit_desc = '' try: bit_access = bit_el.getElements ('ACCESS')[0].getData () except IndexError: bit_access = 'FIXME!'
def dump_ioregs (root): path = ['AVRPART', 'MEMORY', 'IO_MEMORY'] io_mem = root.getSubTree (path) ioregs = io_mem.getElements () ioreg_info_dict = gather_io_info (root) print ' <ioregisters>' # Skip the first 6 elements since they are just give start and stop # addresses. for ioreg in ioregs[6:]: name = ioreg.name...
nrww_start = 'nrww_start="0x%x"' % (int (data, 16))
if data == 'x': nrww_start = '' else: nrww_start = 'nrww_start="0x%x"' % (int (data, 16))
def dump_boot_info (root): path = ['AVRPART', 'MEMORY', 'BOOT_CONFIG'] info = root.getSubTree (path) if info: # The device has bootloader support. data = info.getElements ('NRWW_START_ADDR')[0].getData () if data[0] == '$': data = '0x' + data[1:] nrww_start = 'nrww_start="0x%x"' % (int (data, 16)) data = info.getEle...
nrww_end = 'nrww_end="0x%x"' % (int (data, 16))
if data == 'x': nrww_end = '' else: nrww_end = 'nrww_end="0x%x"' % (int (data, 16))
def dump_boot_info (root): path = ['AVRPART', 'MEMORY', 'BOOT_CONFIG'] info = root.getSubTree (path) if info: # The device has bootloader support. data = info.getElements ('NRWW_START_ADDR')[0].getData () if data[0] == '$': data = '0x' + data[1:] nrww_start = 'nrww_start="0x%x"' % (int (data, 16)) data = info.getEle...
rww_start = 'rww_start="0x%x"' % (int (data, 16))
if data == 'x': rww_start = '' else: rww_start = 'rww_start="0x%x"' % (int (data, 16))
def dump_boot_info (root): path = ['AVRPART', 'MEMORY', 'BOOT_CONFIG'] info = root.getSubTree (path) if info: # The device has bootloader support. data = info.getElements ('NRWW_START_ADDR')[0].getData () if data[0] == '$': data = '0x' + data[1:] nrww_start = 'nrww_start="0x%x"' % (int (data, 16)) data = info.getEle...
rww_end = 'rww_end="0x%x"' % (int (data, 16))
if data == 'x': rww_end = '' else: rww_end = 'rww_end="0x%x"' % (int (data, 16))
def dump_boot_info (root): path = ['AVRPART', 'MEMORY', 'BOOT_CONFIG'] info = root.getSubTree (path) if info: # The device has bootloader support. data = info.getElements ('NRWW_START_ADDR')[0].getData () if data[0] == '$': data = '0x' + data[1:] nrww_start = 'nrww_start="0x%x"' % (int (data, 16)) data = info.getEle...
print ' <bootloader %s %s %s' % (pagesize, nrww_start, nrww_end) print ' %s %s>' % (rww_start, rww_end)
nrww = ' %s %s' % (nrww_start, nrww_end) print ' <bootloader %s %s %s%s' % (pagesize, rww_start, rww_end, nrww)
def dump_boot_info (root): path = ['AVRPART', 'MEMORY', 'BOOT_CONFIG'] info = root.getSubTree (path) if info: # The device has bootloader support. data = info.getElements ('NRWW_START_ADDR')[0].getData () if data[0] == '$': data = '0x' + data[1:] nrww_start = 'nrww_start="0x%x"' % (int (data, 16)) data = info.getEle...
start = 'start="0x%x"' % (int (data,16))
if data == 'x': start = 'start="FIXME: Broken xml from Atmel!"' else: start = 'start="0x%x"' % (int (data,16))
def dump_boot_info (root): path = ['AVRPART', 'MEMORY', 'BOOT_CONFIG'] info = root.getSubTree (path) if info: # The device has bootloader support. data = info.getElements ('NRWW_START_ADDR')[0].getData () if data[0] == '$': data = '0x' + data[1:] nrww_start = 'nrww_start="0x%x"' % (int (data, 16)) data = info.getEle...
lastline = ''
def create_tabs (string): "Create a number of tabs according to the length of string" x = '' lim = (32 - len(string) + 7) / 8 if lim <= 0: lim = 1 for i in range(0, lim): x += "\t" return x
newh = open(header, "w") for line in h:
lines = h.readlines() h.close() firstidx = 0 lastidx = -1 parseddev = parser.getContentHandler().dev for idx, line in enumerate(lines):
def create_tabs (string): "Create a number of tabs according to the length of string" x = '' lim = (32 - len(string) + 7) / 8 if lim <= 0: lim = 1 for i in range(0, lim): x += "\t" return x
key = m.group(2) ele = parser.getContentHandler().dev.interrupts[key] if 1: if len(ele.description.data) > 0: newh.write("/* " + ele.description.data + " */\n") newh.write(" create_tabs(ele.sig_name.data) + "_VECTOR(" + key + ")\n") for x in ele.alt_name.data: newh.write(" create_tabs(x) + "_VECTOR(" + key + ")\n\n") ...
if firstidx == 0: firstidx = idx key = m.group(4) ele = parseddev.interrupts[key] lastidx = idx if idx > 0 and lines[idx - 1].find(ele.description.data) >= 0: if idx - 1 < firstidx: firstidx = idx - 1 if re.match('^$', lines[idx + 1]): lastidx = idx + 1 del lines[firstidx:lastidx] keys = parseddev.interrupts.k...
def create_tabs (string): "Create a number of tabs according to the length of string" x = '' lim = (32 - len(string) + 7) / 8 if lim <= 0: lim = 1 for i in range(0, lim): x += "\t" return x
newh.write(line) else: newh.write(line) lastline = line
docs[ele.sig_name.data][2].append(devname) except KeyError: if type(devname) is TupleType: docs[ele.sig_name.data] = (ele.alt_name.data, ele.description.data, []) for d in devname: docs[ele.sig_name.data][2].append(d) else: docs[ele.sig_name.data] = (ele.alt_name.data, ele.description.data, [devname]) lines.insert(fi...
def create_tabs (string): "Create a number of tabs according to the length of string" x = '' lim = (32 - len(string) + 7) / 8 if lim <= 0: lim = 1 for i in range(0, lim): x += "\t" return x
shutil.rmtree( outdir )
if os.path.exists( outdir ): shutil.rmtree( outdir )
def main(): print 'Deleting previous directory...', shutil.rmtree( outdir ) print 'Done!' if not os.path.exists( outdir ): print '\nCreating directory %s...' %( outdir ), os.mkdir( outdir ) print 'Done!' print '\nDownloading style sheet...', data = getData( 'http://www.yellowduck.be/ydf2/wiki/css/wakka.css' ) saveDa...
self.file_chooser_dialog = self.xml.get_widget("file_chooser_dialog")
def __init__(self, gofoto, dir): self.gofoto = gofoto self.dir = dir
self.tv_vcd_chapters.enable_model_drag_dest([('MY_TREE_MODEL_ROW', 0, 0), ('text/plain', 0, 1), ('TEXT', 0, 2), ('STRING', 0, 3)], gtk.gdk.ACTION_DEFAULT)
self.tv_vcd_chapters.enable_model_drag_source(gtk.gdk.BUTTON1_MASK, [('path', 0, 0)], gtk.gdk.ACTION_DEFAULT | gtk.gdk.ACTION_MOVE) self.tv_vcd_chapters.enable_model_drag_dest([('path', 0, 0)], gtk.gdk.ACTION_DEFAULT | gtk.gdk.ACTION_MOVE)
def __init__(self, gofoto, dir): self.gofoto = gofoto self.dir = dir
chapter = row[self.VCD_CLMN_CHTR] mpeg_dir = os.path.join(chapter.album.dir, "mpeg")
name = row[self.VCD_CLMN_NAME] chapter = self.__find_chapter(name)
def on_btn_create_mpegs_clicked(self, widget): print "create mpegs"
if not os.path.exists(mpeg_dir): os.mkdir(mpeg_dir) pass esc_name = chapter.props.name.replace(" ", "_") chapter.esc_name = esc_name chapter.props.mpg_name = os.path.join(mpeg_dir, ("mpg-"+esc_name+".mpg")) chapter.props.sound_name = os.path.join(mpeg_dir, ("snd-"+esc_name+".mp2")) chapter.props.video_name = os.path.jo...
chapter.esc_name = name.replace(" ", "_") chapter.mpg_name = os.path.join(mpeg_dir, ("mpg-"+chapter.esc_name+".mpg")) chapter.sound_name = os.path.join(mpeg_dir, ("snd-"+chapter.esc_name+".mp2")) chapter.video_name = os.path.join(mpeg_dir, ("vid-"+chapter.esc_name+".m2v"))
def on_btn_create_mpegs_clicked(self, widget): print "create mpegs"
chapter.props.wav_name = os.path.join(chapter.mpeg_dir, chapter.esc_name+".wav")
chapter.wav_name = os.path.join(chapter.mpeg_dir, chapter.esc_name+".wav")
def __check_sound(self, chapter): chapter.wav_name_in = os.path.join(chapter.mpeg_dir, chapter.esc_name+"-in.wav") chapter.props.wav_name = os.path.join(chapter.mpeg_dir, chapter.esc_name+".wav") wav_cmd = "madplay '%s' --output=wave:'%s'" join_wav = "qwavjoin -o '%s' '%s'" cut_wav = "qwavcut -d -B %ds '%s'" mp2_cmd = ...
print " creating sound %s" % chapter.props.sound_name if os.access(chapter.props.sound_name, os.F_OK): print " sound %s already exists" % chapter.props.sound_name
print " creating sound %s" % chapter.sound_name if chapter.mp3_name == "": raise "chapter %s: MP3 file was not provided" % chapter.name if not os.access(chapter.mp3_name, os.F_OK): raise "chapter %s: MP3 file was not provided" % chapter.name if os.access(chapter.sound_name, os.F_OK): print " sound %s already exists" ...
def __check_sound(self, chapter): chapter.wav_name_in = os.path.join(chapter.mpeg_dir, chapter.esc_name+"-in.wav") chapter.props.wav_name = os.path.join(chapter.mpeg_dir, chapter.esc_name+".wav") wav_cmd = "madplay '%s' --output=wave:'%s'" join_wav = "qwavjoin -o '%s' '%s'" cut_wav = "qwavcut -d -B %ds '%s'" mp2_cmd = ...
os.system(wav_cmd % (chapter.props.mp3_name, chapter.wav_name_in))
os.system(wav_cmd % (chapter.mp3_name, chapter.wav_name_in))
def __check_sound(self, chapter): chapter.wav_name_in = os.path.join(chapter.mpeg_dir, chapter.esc_name+"-in.wav") chapter.props.wav_name = os.path.join(chapter.mpeg_dir, chapter.esc_name+".wav") wav_cmd = "madplay '%s' --output=wave:'%s'" join_wav = "qwavjoin -o '%s' '%s'" cut_wav = "qwavcut -d -B %ds '%s'" mp2_cmd = ...
video_len = len(chapter.picts)*5
video_len = self.__count_picts_in_chapter(chapter)*5
def __check_sound(self, chapter): chapter.wav_name_in = os.path.join(chapter.mpeg_dir, chapter.esc_name+"-in.wav") chapter.props.wav_name = os.path.join(chapter.mpeg_dir, chapter.esc_name+".wav") wav_cmd = "madplay '%s' --output=wave:'%s'" join_wav = "qwavjoin -o '%s' '%s'" cut_wav = "qwavcut -d -B %ds '%s'" mp2_cmd = ...
chapter.props.wav_name = chapter.wav_name_in os.system(cut_wav % (video_len, chapter.props.wav_name))
chapter.wav_name = chapter.wav_name_in os.system(cut_wav % (video_len, chapter.wav_name))
def __check_sound(self, chapter): chapter.wav_name_in = os.path.join(chapter.mpeg_dir, chapter.esc_name+"-in.wav") chapter.props.wav_name = os.path.join(chapter.mpeg_dir, chapter.esc_name+".wav") wav_cmd = "madplay '%s' --output=wave:'%s'" join_wav = "qwavjoin -o '%s' '%s'" cut_wav = "qwavcut -d -B %ds '%s'" mp2_cmd = ...
os.system(join_wav % (chapter.props.wav_name, files_in)) os.system(cut_wav % (video_len, chapter.props.wav_name))
os.system(join_wav % (chapter.wav_name, files_in)) os.system(cut_wav % (video_len, chapter.wav_name))
def __check_sound(self, chapter): chapter.wav_name_in = os.path.join(chapter.mpeg_dir, chapter.esc_name+"-in.wav") chapter.props.wav_name = os.path.join(chapter.mpeg_dir, chapter.esc_name+".wav") wav_cmd = "madplay '%s' --output=wave:'%s'" join_wav = "qwavjoin -o '%s' '%s'" cut_wav = "qwavcut -d -B %ds '%s'" mp2_cmd = ...
os.system(mp2_cmd % (chapter.props.wav_name, chapter.props.sound_name))
os.system(mp2_cmd % (chapter.wav_name, chapter.sound_name))
def __check_sound(self, chapter): chapter.wav_name_in = os.path.join(chapter.mpeg_dir, chapter.esc_name+"-in.wav") chapter.props.wav_name = os.path.join(chapter.mpeg_dir, chapter.esc_name+".wav") wav_cmd = "madplay '%s' --output=wave:'%s'" join_wav = "qwavjoin -o '%s' '%s'" cut_wav = "qwavcut -d -B %ds '%s'" mp2_cmd = ...
if os.access(chapter.props.wav_name, os.F_OK): os.unlink(chapter.props.wav_name)
if os.access(chapter.wav_name, os.F_OK): os.unlink(chapter.wav_name)
def __check_sound(self, chapter): chapter.wav_name_in = os.path.join(chapter.mpeg_dir, chapter.esc_name+"-in.wav") chapter.props.wav_name = os.path.join(chapter.mpeg_dir, chapter.esc_name+".wav") wav_cmd = "madplay '%s' --output=wave:'%s'" join_wav = "qwavjoin -o '%s' '%s'" cut_wav = "qwavcut -d -B %ds '%s'" mp2_cmd = ...
for pict in chapter.picts:
for pict in self.album.picts: if pict.props.vcd_chapter != chapter.name or not pict.props.vcd_included: continue
def __check_picts(self, chapter): print " converting picts.." convert_cmd1 = "convert -resize 704x576! '%s' '%s'" convert_cmd2 = "convert -resize 704x576 '%s' '%s'" convert_cmd3 = "convert -border %dx0 -bordercolor black '%s' '%s'"