rem
stringlengths
0
322k
add
stringlengths
0
2.05M
context
stringlengths
8
228k
print 'dirname:',dirname
def processDir (self, dummy, dirname, items):
print item
def processDir (self, dummy, dirname, items):
result.dump (0)
def filterMakefile (p, item, tag): '''Filter certain descriptions out of a makefile. The filename is mentioned as the first item in the list of files of the current contents.Item.''' filename = os.path.join (p.contents.basedir, item.files[0]) words = string.split (tag.content[0].text, ',') parts = [] for word in words...
print '%s missing' % filename
def processItem (p, xmlfile, item): # Strip whilespace before the first text element list = item.content[:] #print '1',list i = 0 while i < len (list): if isinstance (list[i], xmlsupport.Text): if string.strip (list[i].text) != '': break del list[i] else: if isinstance (list[i], xmlsupport.Tag): if not list[i].name in...
sys.stderr.write ('Processing %s...\n' % filename)
def __init__ (self, filename):
print `para`
def filterMakefile (p, item, tag): filename = os.path.join (p.contents.basedir, item.files[0]) words = string.split (tag.content[0].text, ',') parts = [] for word in words: parts.append (string.strip (word)) list = [] mode = 'search' for line in fileinput.input (filename): if mode == 'search': if line[:12] == '# BEG...
print 'item:',name,`para`
def filterMakefile (p, item, tag): filename = os.path.join (p.contents.basedir, item.files[0]) words = string.split (tag.content[0].text, ',') parts = [] for word in words: parts.append (string.strip (word)) list = [] mode = 'search' for line in fileinput.input (filename): if mode == 'search': if line[:12] == '# BEG...
lib.header.append (isLocal, line) header.append (isLocal, line)
lib.header.append ((isLocal, line)) header.append ((isLocal, line))
def processArchive (self, filename):
pos = 0 while 1: match = self.newLinePattern.search (text, pos) if not match: break self.lineno = self.lineno + 1 pos = match.end (0)
self.lineno = self.lineno + self.calcNewLines (text, 0, len (text))
def readText (self):
def calcNewLines (str, start, end):
def calcNewLines (self, str, start, end):
def calcNewLines (str, start, end):
match = self.newLinePattern (text, pos, end)
match = self.newLinePattern.search (str, pos, end)
def calcNewLines (str, start, end):
self.lineno = self.lineno + 1
count = count + 1
def calcNewLines (str, start, end):
error ('Missing argument name in line %d\n' % self.lineno)
self.error ('Missing argument name in line %d\n' % self.lineno)
def readCmd (self):
"Write a line to the output stream. This also writes an EOL to the
"""Write a line to the output stream. This also writes an EOL to the
def writeline (self, str):
isLocal = 0
def processArchive (self, filename):
headers['Date'] = time.strftime("%a, %d %b %Y %X GMT", time.gmtime())
headers['Date'] = time.strftime("%a, %d %b %Y %H:%M:%S GMT", time.gmtime())
def add_aws_auth_header(self, headers, method, path): if not headers.has_key('Date'): headers['Date'] = time.strftime("%a, %d %b %Y %X GMT", time.gmtime())
return handler.rs.VisibilityTimeout
return int(handler.rs.VisibilityTimeout)
def get_timeout(self): path = '%s' % self.id response = self.connection.make_request('GET', path) body = response.read() if response.status >= 300: raise SQSError(response.status, response.reason, body) handler = XmlHandler(self, {}) xml.sax.parseString(body, handler) self.connection._last_rs = handler.rs return handle...
self.is_secure = is_secure self.server = server
def __init__(self, server, aws_access_key_id=None, aws_secret_access_key=None, is_secure=True, port=None, debug=False):
if (is_secure): self.connection = httplib.HTTPSConnection("%s:%d" % (server, port)) else: self.connection = httplib.HTTPConnection("%s:%d" % (server, port))
self.make_http_connection() self._last_rs = None def make_http_connection(self): if self.debug: print 'establishing HTTP connection' if (self.is_secure): self.connection = httplib.HTTPSConnection("%s:%d" % (self.server, self.port)) else: self.connection = httplib.HTTPConnection("%s:%d" % (self.server, self.port))
def __init__(self, server, aws_access_key_id=None, aws_secret_access_key=None, is_secure=True, port=None, debug=False):
self._last_rs = None
def __init__(self, server, aws_access_key_id=None, aws_secret_access_key=None, is_secure=True, port=None, debug=False):
return self.connection.getresponse()
try: return self.connection.getresponse() except httplib.HTTPException, e: self.make_http_connection() self.connection.request(method, path, data, final_headers) return self.connection.getresponse()
def make_request(self, method, path, headers=None, data='', metadata=None): if headers == None: headers = {} if metadata == None: metadata = {} final_headers = merge_meta(headers, metadata); # add auth header self.add_aws_auth_header(final_headers, method, path)
headers = {'ETag':self.md5}
headers = {'Content-MD5':self.base64md5}
def send_file(self, fp): http_conn = self.bucket.connection.connection headers = {'ETag':self.md5} if self.content_type: headers['Content-Type'] = self.content_type headers['Content-Length'] = self.size final_headers = boto.connection.merge_meta(headers, {}); path = '/%s/%s' % (self.bucket.name, urllib.quote_plus(self....
l = self.get_messages(page_size, vtimeout
l = self.get_messages(page_size, vtimeout)
def clear(self, page_size=100, vtimeout=10): """Utility function to remove all messages from a queue""" n = 0 l = self.get_messages(page_size, vtimeout while l: for m in l: self.delete_message(m) n += 1 l = self.get_messages(page_size, vtimeout) return n
self.body = body
self.set_body(body)
def __init__(self, queue=None, body=''): self.queue = queue self.body = body self.id = None
self.parse_body(value)
self.set_body(value)
def __setattr__(self, key, value): if key == 'MessageBody': self.parse_body(value) self.__dict__['body'] = value elif key == 'MessageId': self.__dict__['id'] = value else: self.__dict__[key] = value
def parse_body(self, body): pass
def set_body(self, body): self.body = body
def parse_body(self, body): pass
self.set_debug(debug)
self.set_debug(self.debug)
def make_http_connection(self): if self.debug: print 'establishing HTTP connection' if (self.is_secure): self.connection = httplib.HTTPSConnection("%s:%d" % (self.server, self.port)) else: self.connection = httplib.HTTPConnection("%s:%d" % (self.server, self.port)) self.set_debug(debug)
if self.etag != self.md5:
if self.etag != '"%s"' % self.md5:
def send_file(self, fp): http_conn = self.bucket.connection.connection headers = {'Content-MD5':self.base64md5} if self.content_type: headers['Content-Type'] = self.content_type headers['Content-Length'] = self.size final_headers = boto.utils.merge_meta(headers, self.metadata); path = '/%s/%s' % (self.bucket.name, self...
self.md5 = '"%s"' % m.hexdigest()
self.md5 = m.hexdigest()
def _compute_md5(self, fp): m = md5.new() s = fp.read(4096) while s: m.update(s) s = fp.read(4096) self.md5 = '"%s"' % m.hexdigest() self.base64md5 = base64.b64encode(m.digest()) self.size = fp.tell() fp.seek(0)
self._compute_md5(fp)
if self.md5 == None: self._compute_md5(fp)
def set_contents_from_file(self, fp): if self.bucket != None: self._compute_md5(fp) if hasattr(fp, 'name'): self.content_type = mimetypes.guess_type(fp.name)[0] self.send_file(fp)
print('Generated %d/%d images', ind, len(jstates))
print('Generated {}/{} images'.format(ind, len(jstates)))
def _generate_game_images(self, jstates): '''Generates frames for video.''' # We need filenames with leading zeroes for ffmpeg zero_count = int(log10(len(jstates)) + 1) file_list = [] self.ext = None for ind, jstate in enumerate(jstates): print('Generated %d/%d images', ind, len(jstates)) image = self.painter.paint(jst...
print('Generated {}/{} images'.format(ind+1, len(jstates)))
print('Generating {}/{} images'.format(ind, len(jstates)))
def _generate_game_images(self, jstates): '''Generates frames for video.''' # We need filenames with leading zeroes for ffmpeg zero_count = int(log10(len(jstates)) + 1) file_list = [] self.ext = None for ind, jstate in enumerate(jstates): print('Generated {}/{} images'.format(ind+1, len(jstates))) image = self.painter....
.split(), stdout=fnull, stderr=fnull,
.split(), stderr=fnull,
def compile(self, output_name): ''' Compiles all games given by the specified filemask into one video file. The file will be saved into the log folder. ''' controllers = [] for filename in os.listdir(self.working_dir): if re.search(self.file_mask, filename): controllers.append(self._get_game_controller(os.path.join( se...
image.save("test-1.png", "PNG")
def paint(self, jury_state): ''' Paints the state of the game; Returns the string --- bits of the jpeg image. ''' if not self._is_initialized: self._initialize(jury_state)
class SparseVector(DictionaryWithDefault): def __init__(self): DictionaryWithDefault.__init__(self, lambda x: 0.) def add_to(self, other, factor = 1.): for key in self: other[key] += factor * self[key] def add_to_matrix_column(self, matrix, column, factor = 1.): for key in self: matrix[key, column] += factor * self[k...
def negate_tuple(t1): return tuple([-t1v for t1v in t1])
JOB_TIMES = tools.DictionaryWithDefault(lambda x: 0) PRINT_JOBS = tools.Reference(True)
JOB_TIMES = pytools.DictionaryWithDefault(lambda x: 0) PRINT_JOBS = pytools.Reference(True)
def print_job_summary(): for key in JOB_TIMES: print key, " " * (50-len(key)), JOB_TIMES[key]
def expect(self, tag): if not self.is_next(tag): self.expected(str(tag)) self.advance()
def expect(self, tag): if not self.is_next(tag): self.expected(str(tag)) self.advance()
msgid = normalize(tmpstream.getvalue())
msgid = default
def do_insertTranslation(self, stuff): i18ndict = {} srepr = [] obj = None self.i18nStack.append((i18ndict, srepr)) msgid = stuff[0] # We need to evaluate the content of the tag because that will give us # several useful pieces of information. First, the contents will # include an implicit message id, if no explicit o...
print file
def write(self, s): pass
def evalaluate(*args):
def evaluate(*args):
def evalaluate(*args): return '' # who cares
return _nulljoin(text.split())
return _spacejoin(text.split())
def normalize(text): # Now we need to normalize the whitespace in implicit message ids and # implicit $name substitution values by stripping leading and trailing # whitespace, and folding all internal whitespace to a single space. return _nulljoin(text.split())
if (version == TAL_VERSION and isinstance(program[1], tuple) and
if (version == TAL_VERSION and isinstance_(program[1], tuple) and
def getProgramMode(program): version = getProgramVersion(program) if (version == TAL_VERSION and isinstance(program[1], tuple) and len(program[1]) == 2): opcode, mode = program[1] if opcode == "mode": return mode return None
isinstance(program[0], tuple) and len(program[0]) == 2):
isinstance_(program[0], tuple) and len(program[0]) == 2):
def getProgramVersion(program): if (len(program) >= 2 and isinstance(program[0], tuple) and len(program[0]) == 2): opcode, version = program[0] if opcode == "version": return version return None
if macro is None: return ()
def attrAction(self, item): name, value, action = item[:3] if action == 'insert': return () macs = self.macroStack if action == 'metal' and self.metal and macs: # Drop all METAL attributes at a use-depth beyond the first # use-macro and its extensions if len(macs) > 1: for macro in macs[1:]: if macro is None: return ()...
if len(macs) == 1: entering = macs[-1][4] if not entering: macs.append(None) self.interpret(macro) assert macs[-1] is None macs.pop() return
def do_defineMacro(self, (macroName, macro)): macs = self.macroStack wasInUse = self.inUseDirective self.inUseDirective = False if len(macs) == 1: entering = macs[-1][4] if not entering: macs.append(None) self.interpret(macro) assert macs[-1] is None macs.pop() return self.interpret(macro) self.inUseDirective = wasInUs...
if macs and macs[-1] is not None:
if macs:
def do_defineSlot(self, (slotName, block)): if not self.metal: self.interpret(block) return macs = self.macroStack if macs and macs[-1] is not None: len_macs = len(macs) # Measure the extension depth of this use-macro depth = 1 while depth < len_macs: if macs[-depth][3]: depth += 1 else: break # Search for a slot fille...
self.interpret(slot) if self.sourceFile != prev_source: self.engine.setSourceFile(prev_source) self.sourceFile = prev_source for mac in chopped: mac.entering = False macs.extend(chopped)
try: self.interpret(slot) finally: if self.sourceFile != prev_source: self.engine.setSourceFile(prev_source) self.sourceFile = prev_source for mac in chopped: mac.entering = False macs.extend(chopped)
def do_defineSlot(self, (slotName, block)): if not self.metal: self.interpret(block) return macs = self.macroStack if macs: len_macs = len(macs) # Measure the extension depth of this use-macro depth = 1 while depth < len_macs: if macs[-depth].extending: depth += 1 else: break # Search for a slot filler from the most sp...
import re
def __init__(self, err, position=(None, None)): if isinstance(err, Exception): self.type = err.__class__ self.value = err else: self.type = err self.value = None self.lineno = position[0] self.offset = position[1]
del re
def __init__(self, err, position=(None, None)): if isinstance(err, Exception): self.type = err.__class__ self.value = err else: self.type = err self.value = None self.lineno = position[0] self.offset = position[1]
import re
def getProgramVersion(program): if (len(program) >= 2 and isinstance(program[0], tuple) and len(program[0]) == 2): opcode, version = program[0] if opcode == "version": return version return None
del re
def getProgramVersion(program): if (len(program) >= 2 and isinstance(program[0], tuple) and len(program[0]) == 2): opcode, version = program[0] if opcode == "version": return version return None
for spec in i18nattrs.split(";"):
attrs = filter(None, i18nattrs.split(";")) for spec in attrs:
def _parseI18nAttributes(i18nattrs, position, xml): d = {} for spec in i18nattrs.split(";"): parts = spec.split() if len(parts) > 2: raise TALError("illegal i18n:attributes specification: %r" % spec, position) if len(parts) == 2: attr, msgid = parts else: # len(parts) == 1 attr = parts[0] msgid = None if not xml: attr ...
self._run_check("""<a a.b='v' c:d='v' e-f='v'/>""", [ ("starttag", "a", ["a.b", "v", "c:d", "v", "e-f", "v"]),
self._run_check("""<a a.b='v' e-f='v'/>""", [ ("starttag", "a", ["a.b", "v", "e-f", "v"]),
def test_attr_funky_names(self): self._run_check("""<a a.b='v' c:d='v' e-f='v'/>""", [ ("starttag", "a", ["a.b", "v", "c:d", "v", "e-f", "v"]), ("endtag", "a"), ])
markup cnotained in the result string will be interpreted.
markup contained in the result string will be interpreted.
def evaluateStructure(compiled_expression): """Evaluate an expression that must return a structured document fragment.
tal_fn = 'benchmark/tal%.2d.html' dtml_fn = 'benchmark/dtml%.2d.html'
try: fname = __file__ except NameError: fname = sys.argv[0] taldir = os.path.dirname(os.path.dirname(os.path.abspath(fname))) benchdir = os.path.join(taldir, 'benchmark') tal_fn = os.path.join(benchdir, 'tal%.2d.html') dtml_fn = os.path.join(benchdir, 'dtml%.2d.html')
def profile_tal(fn, count, profiler): p = HTMLTALParser() p.parseFile(fn) program, macros = p.getCode() engine = DummyEngine(macros) engine.globals = data tal = TALInterpreter(program, macros, engine, StringIO(), wrap=0, tal=1, strictinsert=0) for i in range(4): tal() r = [None] * count for i in r: profiler.runcall(tal...
verbose = 1
runtests = False verbose = True
def main(count, profiler=None, verbose=1): n = 1 if verbose: print '##: %10s %10s %10s' % ('ZPT', 'TAL', 'DTML') while os.path.isfile(tal_fn % n) and os.path.isfile(dtml_fn % n): compare(n, count, profiler, verbose) n = n + 1
opts, args = getopt.getopt(sys.argv[1:], "pq")
opts, args = getopt.getopt(sys.argv[1:], "pqt")
def main(count, profiler=None, verbose=1): n = 1 if verbose: print '##: %10s %10s %10s' % ('ZPT', 'TAL', 'DTML') while os.path.isfile(tal_fn % n) and os.path.isfile(dtml_fn % n): compare(n, count, profiler, verbose) n = n + 1
verbose = 0
verbose = False elif opt == "-t": runtests = True
def main(count, profiler=None, verbose=1): n = 1 if verbose: print '##: %10s %10s %10s' % ('ZPT', 'TAL', 'DTML') while os.path.isfile(tal_fn % n) and os.path.isfile(dtml_fn % n): compare(n, count, profiler, verbose) n = n + 1
if len(args) > 1:
if runtests: srcdir = os.path.dirname(os.path.dirname(taldir)) topdir = os.path.dirname(srcdir) pwd = os.getcwd() os.chdir(topdir) rc = os.spawnl(os.P_WAIT, sys.executable, sys.executable, "test.py", "zope.tal.tests") if rc > 0: sys.exit(rc) elif rc < 0: sig = -rc print >>sys.stderr, ( "Process exited, signal %d (%s)...
def main(count, profiler=None, verbose=1): n = 1 if verbose: print '##: %10s %10s %10s' % ('ZPT', 'TAL', 'DTML') while os.path.isfile(tal_fn % n) and os.path.isfile(dtml_fn % n): compare(n, count, profiler, verbose) n = n + 1
logging.warn('TAL/i18n: Message id %s was not found in the translation table; using default text.' % msgid)
logging.warn('TAL/i18n: Message id %s was not found in the ' 'translation table; using default text: %s' % (msgid, default))
def do_insertTranslation(self, stuff): i18ndict = {} srepr = [] obj = None self.i18nStack.append((i18ndict, srepr)) msgid = stuff[0] # We need to evaluate the content of the tag because that will give us # several useful pieces of information. First, the contents will # include an implicit message id, if no explicit o...
value = self.i18n_attribute(value)
translated = self.i18n_attribute(value) if translated is not None: value = translated
def attrAction_tal(self, item): name, value, action = item[:3] if action in ('metal', 'tal', 'xmlns', 'i18n'): return self.attrAction(item) ok = 1 expr, msgid = item[3:] if self.html and name.lower() in BOOLEAN_HTML_ATTRS: evalue = self.engine.evaluateBoolean(item[3]) if evalue is self.Default: if action == 'insert': #...
def factory(self, msgid, default, mapping={}): m = MessageID(msgid, default)
def factory(self, msgid, default=None, mapping={}): m = MessageID(msgid, default=default)
def factory(self, msgid, default, mapping={}): m = MessageID(msgid, default) m.mapping = mapping return m
def factory(self, msgid, default, mapping={}): return Message(msgid, default, mapping=mapping)
def factory(self, msgid, default=None, mapping={}): return Message(msgid, default=default, mapping=mapping)
def factory(self, msgid, default, mapping={}): return Message(msgid, default, mapping=mapping)
if character.isalnum():
if character != ' ':
def recognize(self): """Try to convert ASCII are to vector graphics.""" #XXX search for symbols #~ #search for long strings #~ for y in range(self.height): #~ for x in range(self.width): #~ character = self.image[y][x] #~ if self.classification[y][x] is None: #~ if character.isalnum(): #~ self.shapes.extend(self._follo...
return p1-direction_vector*0.5, [ Line(p1-direction_vector, p1-direction_vector*0.5j), Line(p1-direction_vector, p1-direction_vector*-0.5j)
return p1-direction_vector*1.5, [ Line(p1-direction_vector*1.5, p1-direction_vector*0.5j), Line(p1-direction_vector*1.5, p1-direction_vector*-0.5j)
def _reversed_arrow(self, p1, p2): """--<""" direction_vector = p1 - p2 direction_vector /= abs(direction_vector) return p1-direction_vector*0.5, [ Line(p1-direction_vector, p1-direction_vector*0.5j), Line(p1-direction_vector, p1-direction_vector*-0.5j) ]
return p1-direction_vector, [ Rectangle(p1-direction_vector-direction_vector*(0.77+0.77j), p1-direction_vector+direction_vector*(0.77+0.77j))
return p1-direction_vector*1.414, [ Rectangle(p1-direction_vector-direction_vector*(0.707+0.707j), p1-direction_vector+direction_vector*(0.707+0.707j))
def _rectangular_head(self, p1, p2): direction_vector = p1 - p2 direction_vector /= abs(direction_vector) return p1-direction_vector, [ Rectangle(p1-direction_vector-direction_vector*(0.77+0.77j), p1-direction_vector+direction_vector*(0.77+0.77j)) ]
if (self.get(x+1, y) == '-' and self.get(x, y+1) == '|'): return [Line( Point(x*NOMINAL_SIZE+CENTER, y*NOMINAL_SIZE+BOTTOM), Point(x*NOMINAL_SIZE+RIGHT, y*NOMINAL_SIZE+CENTER) )] if (self.get(x-1, y) == '-' and self.get(x, y-1) == '|'): return [Line( Point(x*NOMINAL_SIZE+CENTER, y*NOMINAL_SIZE+TOP), Point(x*NOMINAL_SIZ...
result = [] if self.get(x, y) == '/': if (self.get(x+1, y) == '-' and self.get(x, y+1) == '|'): result.append(Line( Point(x*NOMINAL_SIZE+CENTER, y*NOMINAL_SIZE+BOTTOM), Point(x*NOMINAL_SIZE+RIGHT, y*NOMINAL_SIZE+CENTER) )) if (self.get(x-1, y) == '-' and self.get(x, y-1) == '|'): result.append(Line( Point(x*NOMINAL_SI...
def _follow_rounded_edge(self, x, y): """check for rounded edges: /- | -\- | | -/ | \- """ #XXX return Arc shapes, not lines if (self.get(x+1, y) == '-' and self.get(x, y+1) == '|'): return [Line( Point(x*NOMINAL_SIZE+CENTER, y*NOMINAL_SIZE+BOTTOM), Point(x*NOMINAL_SIZE+RIGHT, y*NOMINAL_SIZE+CENTE...
output_path = '.' print output_path output_name = os.path.join(output_path, 'aafigure-%i.svg' % aafigure_counter)
output_name = 'aafigure-%i.svg' % aafigure_counter
def AAFigureDrective (name, arguments, options, content, lineno, content_offset, block_text, state, state_machine): text = '\n'.join(content) global aafigure_counter aafigure_counter += 1 output_path = '.' print output_path output_name = os.path.join(output_path, 'aafigure-%i.svg' % aafigure_counter) aaimg = aafigure...
if firstPoint and firstVolume:
if firstPoint != None and firstVolume != None:
def AddAudioFadePoints(self, firstPoint, secondPoint, firstVolume, secondVolume): """ Add the two passed points to the audioFadePoints list. If either point exists already, replace it, and resort the list by time. undo : RemoveAudioFadePoints: temp, temp2, temp3, temp4 """ #for command manager to use with undo self.te...
if secondPoint and secondVolume:
if secondPoint != None and secondVolume != None:
def AddAudioFadePoints(self, firstPoint, secondPoint, firstVolume, secondVolume): """ Add the two passed points to the audioFadePoints list. If either point exists already, replace it, and resort the list by time. undo : RemoveAudioFadePoints: temp, temp2, temp3, temp4 """ #for command manager to use with undo self.te...
chooser.set_current_folder(self.mainview.defaultlocation)
chooser.set_current_folder(self.defaultlocation)
def OnOpenProject(self, widget, destroyCallback=None): chooser = gtk.FileChooserDialog((_('Choose a Jokosher project file')), None, gtk.FILE_CHOOSER_ACTION_OPEN, (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, gtk.STOCK_OPEN, gtk.RESPONSE_OK)) chooser.set_current_folder(self.mainview.defaultlocation)
for instr in self.project.instruments: if instr.isSelected: instrSelected = True break else: for ev in instr.events: if ev.isSelected: eventSelected = True
if self.project: for instr in self.project.instruments: if instr.isSelected: instrSelected = True break else: for ev in instr.events: if ev.isSelected: eventSelected = True
def OnEditMenu(self, widget): #HACK: when the edit menu opens, check if any events or #instruments are selected and set the cut, copy, paste and delete accordingly instrSelected = False eventSelected = False for instr in self.project.instruments: if instr.isSelected: instrSelected = True break else: for ev in instr.eve...
self.project.transport.SetBPM(float(self.bpmedit.get_text()))
newbpm = float(self.bpmedit.get_text()) if newbpm > 400: newbpm = 400.0 self.project.transport.SetBPM(newbpm)
def OnAcceptEditBPM(self, widget=None): if self.bpmeditPacked: self.bpmframe.remove(self.bpmedit) self.project.transport.SetBPM(float(self.bpmedit.get_text())) self.bpmlabel.set_use_markup(True) self.bpmlabel.set_markup("<span foreground='#0b410b'><b>%d</b></span>"%self.project.transport.bpm) self.bpmframe.add(self....
vol = 0.99 Globals.debug("FADE POINT: time(%.2f) vol(%.2f)" % (ev.start + point[0], vol)) self.control.set("volume", (ev.start + point[0]) * gst.SECOND, vol)
vol = 0.99
def PrepareController(self): """Fills the gst.Controller for the instrument with its list of fade times.""" Globals.debug("Preparing the controller") self.control.unset_all("volume") for ev in self.events: for point in ev.audioFadePoints: if point[1] == 1.0: vol = 0.99 Globals.debug("FADE POINT: time(%.2f) vol(%.2f)" ...
Globals.debug("FADE POINT: time(%.2f) vol(%.2f)" % (ev.start + point[0], point[1])) self.control.set("volume", (ev.start + point[0]) * gst.SECOND, point[1])
Globals.debug("FADE POINT: time(%.2f) vol(%.2f)" % (ev.start + point[0], vol)) self.control.set("volume", (ev.start + point[0]) * gst.SECOND, vol)
def PrepareController(self): """Fills the gst.Controller for the instrument with its list of fade times.""" Globals.debug("Preparing the controller") self.control.unset_all("volume") for ev in self.events: for point in ev.audioFadePoints: if point[1] == 1.0: vol = 0.99 Globals.debug("FADE POINT: time(%.2f) vol(%.2f)" ...
for instr in mainapp.projects.instruments:
for instr in self.mainapp.projects.instruments:
def add_file_to_instrument(self, instr_id, uri, position=0): """ Creates a new event from the file at the given URI and adds it to the instrument with id 'instr_id' at position (in seconds). Return values: 0: success 1: bad URI or file could not be loaded 2: instrument with id 'instr_id' not found """ for instr in main...
newDict = joinEvent.copy()
newDict = joinEvent.__fadePointsDict.copy()
def join_event(self, joinEvent, joinToRight=True): """helper function for Join() and Trim(). All other methods and classes should not invoke this function directly since there is no undo for it. After joining the events on either side, this method will not remove the event from the instrument lane. This must be done f...
length = self.project.GetProjectLength()
length = self.project.GetProjectLength() + self.EXTRA_SCROLL_TIME
def OnExpose(self, widget, event): """ Sets scrollbar properties once space has been allocated """ # calculate scrollable width - allow 4 pixels for borders self.scrollRange.page_size = (self.allocation.width - Globals.INSTRUMENT_HEADER_WIDTH - 4) / self.project.viewScale self.scrollRange.page_increment = self.scrollR...
if start != self.project.SetViewStart:
if start != self.project.viewStart:
def OnExpose(self, widget, event): """ Sets scrollbar properties once space has been allocated """ # calculate scrollable width - allow 4 pixels for borders self.scrollRange.page_size = (self.allocation.width - Globals.INSTRUMENT_HEADER_WIDTH - 4) / self.project.viewScale self.scrollRange.page_increment = self.scrollR...
self.bpmedit.set_text(str(self.project.transport.bpm))
self.bpmedit.set_value(self.project.transport.bpm)
def OnEditBPM(self, widget, event): #self.parentUpdateMethod() if event.type == gtk.gdk.BUTTON_PRESS: self.bpmframe.remove(self.bpmeventbox) self.bpmedit = gtk.SpinButton() self.bpmedit.set_range(1, 400) self.bpmedit.set_increments(1, 5) self.bpmedit.set_text(str(self.project.transport.bpm)) self.bpmedit.connect("acti...
availpresets = [x[0] for x in self.presets.effectpresetregistry.items() if x[1].get('instrument')== self.instrument.instrType and x[1]['dependencies'].issubset(Globals.LADSPA_FACTORY_REGISTRY)] for pres in availpresets:
self.availpresets=[] self.availpresets = [x[0] for x in self.presets.effectpresetregistry.items() if x[1].get('instrument')== self.instrument.instrType and x[1]['dependencies'].issubset(Globals.LADSPA_FACTORY_REGISTRY)] for pres in self.availpresets:
def __init__(self, instrument, destroyCallback): """ This constructor enables a bunch of variables, reads in the glade file for the main dialog, and populates the effects and presets combo boxes """ # a reference to the instrument object self.instrument = instrument self.res = gtk.glade.XML(Globals.GLADE_PATH, "Instr...
Globals.debug("not can record")
Globals.debug("can not record") if self.project.instruments: errmsg = "No instruments are armed for recording. You need to arm an instrument before you can begin recording." else: errmsg = "No instruments have been added. You must add an instrument before recording"
def Record(self, widget=None): '''Toggle recording''' # toggling the record button invokes this function so we use the settingButtons var to # indicate that we're just changing the GUI state and dont need to do anything code-wise if self.settingButtons: return if self.isRecording: self.project.stop() self.addInstrume...
_("No instruments are armed for recording. You need to arm an instrument before you can begin recording."))
_(errmsg))
def Record(self, widget=None): '''Toggle recording''' # toggling the record button invokes this function so we use the settingButtons var to # indicate that we're just changing the GUI state and dont need to do anything code-wise if self.settingButtons: return if self.isRecording: self.project.stop() self.addInstrume...
if self.project.IsPlaying:
if self.mainview.isPlaying:
def OnUpdateTimeout(self): """ Called at intervals (self.FPS) to update the VU meters """ if self.project.IsPlaying: self.mastermixer.vu.queue_draw() # redraw VU widgets for each instrument for mix in self.channels: mix.vu.queue_draw() return True else: # kill timeout when play has stopped self.UpdateTimeout = False ...
p._Project__savedUndoStack.append(cmdList)
p._Project__redoStack.append(cmdList)
def LoadFromFile(uri): """ Loads a project from a save file on disk. uri The filesystem location of the project file to load. Currently only file:// URIs are considered valid. """ p = Project() (scheme, domain, projectfile, params, query, fragment) = urlparse.urlparse(uri, "file") if scheme != "file": # raise "The UR...
if not self.audioState == self.AUDIO_EXPORTING:
if not self.GetIsExporting():
def TerminateExport(self, bus=None, message=None): """ GStreamer End Of Stream handler. It is connected to eos on mainpipeline while export is taking place. Parameters: bus -- reserved for GStreamer callbacks, don't use it explicitly. message -- reserved for GStreamer callbacks, don't use it explicitly. """ if not se...
if self.IsExporting:
if self.exportPending or self.GetIsExporting():
def GetExportProgress(self): """ Returns a tuple with the number of seconds exported and the number of total seconds. """ if self.IsExporting: try: #total = self.mainpipeline.query_duration(gst.FORMAT_TIME)[0] total = self.GetProjectLength() * gst.SECOND current = self.mainpipeline.query_position(gst.FORMAT_TIME)[0] ex...
self.state_id = self.bus.connect("message::state-changed", self.state_changed) self.mainpipeline.set_state(gst.STATE_PAUSED) try: if os.environ['JOKOSHER_DEBUG']: Globals.debug("Play Pipeline:") self.debug.ShowPipelineTree(self.mainpipeline) except: pass
self.play()
def record(self): '''Start all selected instruments recording'''
self.window.show_all()
def __init__(self):
EffectPresets().FillEffectsPresetsRegistry() Extension.API = Extension.ExtensionAPI(self) Extension.LoadAllExtensions()
def __init__(self):
@exported_function
def __init__(self, mainapp): self.mainapp = mainapp
@exported_function
def play(self, play_state=True): """ If play_state is True, it will play the project from the beginning. Otherwise, it will stop all playing. """ #Stop current playing (if any) and set to playhead to the beginning self.mainapp.Stop() if play_state: #Commence playing self.mainapp.Play()
@exported_function
def stop(self): """ Stops the project if it is currently playing. Same as play(play_state=False) """ self.mainapp.Stop()
self.window.resize(350, 300) self.window.set_icon(self.parent.icon) self.window.set_transient_for(self.parent.window)
def __init__(self, instrument): self.instrument = instrument self.res = gtk.glade.XML(Globals.GLADE_PATH, "InstrumentEffectsDialog")
self.effect = gst.element_factory_make(self.currentplugin, "effect") self.instrument.effects.append(self.effect)
self.instrument.effects.append(gst.element_factory_make(self.currentplugin, "effect"))
def OnAddEffect(self, combo): print self.currentplugin self.effect = gst.element_factory_make(self.currentplugin, "effect") self.instrument.effects.append(self.effect) button = gtk.Button(self.currentplugin) button.connect("clicked", self.OnEffectSetting) self.effectsbox.pack_end(button) self.effectsbox.show_all()
self.effectsbox.pack_end(button)
self.effectsbox.pack_start(button)
def OnAddEffect(self, combo): print self.currentplugin self.effect = gst.element_factory_make(self.currentplugin, "effect") self.instrument.effects.append(self.effect) button = gtk.Button(self.currentplugin) button.connect("clicked", self.OnEffectSetting) self.effectsbox.pack_end(button) self.effectsbox.show_all()
def OnEffectSetting(self, combo):
def OnEffectSetting(self, button):
def OnEffectSetting(self, combo): print "Showing plugin settings"
proplist = gobject.list_properties(self.effect)
proplist = gobject.list_properties(self.instrument.effects[buttonpos])
def OnEffectSetting(self, combo): print "Showing plugin settings"
print "\tvalue: " + str(self.effect.get_property(property.name))
print "\tvalue: " + str(self.instrument.effects[buttonpos].get_property(property.name))
def OnEffectSetting(self, combo): print "Showing plugin settings"
if config.has_option('i18n', lang):
if lang and config.has_option('i18n', lang):
def _cacheInstrumentsGenerator(): """The current list of instruments, cached""" basepath = os.path.dirname(os.path.abspath(__file__)) instrpath = os.path.join(basepath, "..", "Instruments") files = os.walk(instrpath).next()[2] instrFiles = [x for x in files if x.endswith(".instr")] for f in instrFiles: config = SafeC...