rem
stringlengths
0
322k
add
stringlengths
0
2.05M
context
stringlengths
8
228k
print 'PLOP: %r' % name
def registered_wizard(name): """ Register dynamicaly the wizard """ gname = 'wizard.%s' % name if netsvc.service_exist(gname): if isinstance(netsvc.SERVICES[gname], format_choice): return del netsvc.SERVICES[name] print 'PLOP: %r' % name format_choice(name)
def _register_ref(self, cr, uid, res , ref_id, context=None): """ Search reference on ir.model.data :type res: dict :param res: resource to register :type ref_id: str :param ref_id: unique reference :rtype: integer :return: ID for this reference """ data_obj = self.pool.get('ir.model.data') return data_obj._update(c...
def _get_formats(self, cr, uid, context=None): """ Return the list of all types of document that can be generate by JasperServer """ if not context: context = {} extension_obj = self.pool.get('jasper.document.extension') ext_ids = extension_obj.search(cr, uid, []) extensions = self.pool.get('jasper.document.extension')...
data_obj = self.pool.get('ir.model.data')
def make_action(self, cr, uid, id, context=None): """ If action doesn't exists we must create it """ data_obj = self.pool.get('ir.model.data') b = self.browse(cr, uid, id, context=context) wiz_name = 'jasper.%s' % b.service res = { 'name': b.name, 'wiz_name': wiz_name, 'multi': False, 'model': b.model_id.model, 'jasper...
res = { 'name': b.name, 'wiz_name': wiz_name, 'multi': False, 'model': b.model_id.model, 'jasper': True, } xml_id = 'wizard_jasper_%s' % b.service
def make_action(self, cr, uid, id, context=None): """ If action doesn't exists we must create it """ data_obj = self.pool.get('ir.model.data') b = self.browse(cr, uid, id, context=context) wiz_name = 'jasper.%s' % b.service res = { 'name': b.name, 'wiz_name': wiz_name, 'multi': False, 'model': b.model_id.model, 'jasper...
res_id = self._register_ref(cr, uid, res, xml_id, context=context) keyword = 'client_print_multi' value = 'ir.actions.wizard,%d' % res_id data_obj.ir_set(cr, uid, 'action', keyword, b.name, [b.model_id.model], value, replace=True, isobject=True, xml_id=xml_id)
def make_action(self, cr, uid, id, context=None): """ If action doesn't exists we must create it """ data_obj = self.pool.get('ir.model.data') b = self.browse(cr, uid, id, context=context) wiz_name = 'jasper.%s' % b.service res = { 'name': b.name, 'wiz_name': wiz_name, 'multi': False, 'model': b.model_id.model, 'jasper...
return res_id
def make_action(self, cr, uid, id, context=None): """ If action doesn't exists we must create it """ data_obj = self.pool.get('ir.model.data') b = self.browse(cr, uid, id, context=context) wiz_name = 'jasper.%s' % b.service res = { 'name': b.name, 'wiz_name': wiz_name, 'multi': False, 'model': b.model_id.model, 'jasper...
act_id = self.make_action(cr, uid, doc_id, context=context)
self.make_action(cr, uid, doc_id, context=context)
def create(self, cr, uid, vals, context=None): """ Dynamicaly declare the wizard for this document """ if context is None: context = {} doc_id = super(jasper_document, self).create(cr, uid, vals, context=context) act_id = self.make_action(cr, uid, doc_id, context=context) return doc_id
def unlink(self, cr, uid, ids, context=None): """ When jasper document is delete, delete the print action as well """ if context is None: context = {} for id in ids: jd = self.browse(cr, uid, id, context=context) dom = [ ('name','=', jd.name), ('key2','=', 'client_print_multi'), ('model','=',jd.model_id.model) ] lnk...
def write(self, cr, uid, ids, vals, context=None): """ If the description change, we must update the action """ if context is None: context = {} if not context.get('action'): for id in ids: self.make_action(cr, uid, id, context=context) return super(jasper_document, self).write(cr, uid, ids, vals, context=context)
needsUpdate = False
def update(self, *args): #needsUpdate = False if self.dx != 0 or self.dy != 0: self._modifyLocation(self.dx, self.dy) for sprite in self.mapView: if self.collideFunc(self, sprite) and isImpassable(sprite.mapElement): self._modifyLocation(-self.dx, -self.dy) imWidth, imHeight = self.mapView.imageSize if self.mapView....
if self.dx != 0 or self.dy != 0: self._modifyLocation(self.dx, self.dy)
if self.dx != 0: needsUpdate = True self._modifyLocation(self.dx, 0)
def update(self, *args): #needsUpdate = False if self.dx != 0 or self.dy != 0: self._modifyLocation(self.dx, self.dy) for sprite in self.mapView: if self.collideFunc(self, sprite) and isImpassable(sprite.mapElement): self._modifyLocation(-self.dx, -self.dy) imWidth, imHeight = self.mapView.imageSize if self.mapView....
self._modifyLocation(-self.dx, -self.dy)
self._modifyLocation(-self.dx, 0) if self.dy != 0: needsUpdate = True self._modifyLocation(0, self.dy) for sprite in self.mapView: if self.collideFunc(self, sprite) and isImpassable(sprite.mapElement): self._modifyLocation(0, -self.dy) if needsUpdate:
def update(self, *args): #needsUpdate = False if self.dx != 0 or self.dy != 0: self._modifyLocation(self.dx, self.dy) for sprite in self.mapView: if self.collideFunc(self, sprite) and isImpassable(sprite.mapElement): self._modifyLocation(-self.dx, -self.dy) imWidth, imHeight = self.mapView.imageSize if self.mapView....
self.playerSprite.dx = -speed
self.playerSprite.dx -= speed
def update(self): for event in pygame.event.get(): if event.type == pygame.QUIT: sys.exit() speed = 5
self.playerSprite.dx = speed
self.playerSprite.dx += speed
def update(self): for event in pygame.event.get(): if event.type == pygame.QUIT: sys.exit() speed = 5
self.playerSprite.dy = -speed
self.playerSprite.dy -= speed
def update(self): for event in pygame.event.get(): if event.type == pygame.QUIT: sys.exit() speed = 5
self.playerSprite.dy = speed
self.playerSprite.dy += speed
def update(self): for event in pygame.event.get(): if event.type == pygame.QUIT: sys.exit() speed = 5
self.playerSprite.dx = 0
self.playerSprite.dx += speed
def update(self): for event in pygame.event.get(): if event.type == pygame.QUIT: sys.exit() speed = 5
self.playerSprite.dx = 0
self.playerSprite.dx -= speed
def update(self): for event in pygame.event.get(): if event.type == pygame.QUIT: sys.exit() speed = 5
self.playerSprite.dy = 0
self.playerSprite.dy += speed
def update(self): for event in pygame.event.get(): if event.type == pygame.QUIT: sys.exit() speed = 5
self.playerSprite.dy = 0
self.playerSprite.dy -= speed
def update(self): for event in pygame.event.get(): if event.type == pygame.QUIT: sys.exit() speed = 5
buff = unicode(fp.read(2*length), 'utf-8') return CFString(buff.encode('utf-16be'))
buff = fp.read(2*length) buff = unicode(buff, 'utf-16be') buff = buff.encode('utf-8') return CFString(buff)
def read_binary_unicode_string(self, fname,fp,length): ''' Read a unicode string value, coded as UTF-16BE ''' # The problem is: we get the length of the string IN CHARACTERS; # since a char in UTF-16 can be 16 or 32 bit long, we don't really know # how long the string is in bytes buff = unicode(fp.read(2*length), 'utf-...
major = "j"
major = "i"
def wb_arr2d(self, arr, dim, tp, trim): major = "j" self.declare_var("int "+major) minor = "i" self.declare_var("int "+minor) if trim: self.declare_var("int size") pb = "p%s" % tp[:1] self.declare_var("%s *%s" % (tp, pb)) if trim: jmin = minor+"min" jmax = minor+"max" self.declare_var("int "+jmin) self.declare_var("in...
minor = "i"
minor = "j"
def wb_arr2d(self, arr, dim, tp, trim): major = "j" self.declare_var("int "+major) minor = "i" self.declare_var("int "+minor) if trim: self.declare_var("int size") pb = "p%s" % tp[:1] self.declare_var("%s *%s" % (tp, pb)) if trim: jmin = minor+"min" jmax = minor+"max" self.declare_var("int "+jmin) self.declare_var("in...
self.addln("for (%s = 0, %s = %s-1; %s >= 0 && %s[%s] > 0.0; %s--) ;",
self.addln("for (%s = 0, %s = %s-1; %s >= 0 && %s[%s] <= 0.0; %s--) ;",
def wb_arr2d(self, arr, dim, tp, trim): major = "j" self.declare_var("int "+major) minor = "i" self.declare_var("int "+minor) if trim: self.declare_var("int size") pb = "p%s" % tp[:1] self.declare_var("%s *%s" % (tp, pb)) if trim: jmin = minor+"min" jmax = minor+"max" self.declare_var("int "+jmin) self.declare_var("in...
self.addln("for (%s = 0; %s < %s && %s[%s] > 0.0; %s++) ;",
self.addln("for (%s = 0; %s < %s && %s[%s] <= 0.0; %s++) ;",
def wb_arr2d(self, arr, dim, tp, trim): major = "j" self.declare_var("int "+major) minor = "i" self.declare_var("int "+minor) if trim: self.declare_var("int size") pb = "p%s" % tp[:1] self.declare_var("%s *%s" % (tp, pb)) if trim: jmin = minor+"min" jmax = minor+"max" self.declare_var("int "+jmin) self.declare_var("in...
return merge_blocks(lines, r"\s*if\s*\(.*\)\s*{$", "if", r"}\s*else", "}")
return merge_blocks(lines, r"\s*if\s*\(.*\)\s*{$", "if", r"\s*(\})\s*else", "}")
def merge_if_blocks(lines): ''' merge neighboring if-blocks with the same condition if (abc) { ... X } X if (abc) { ... } ''' return merge_blocks(lines, r"\s*if\s*\(.*\)\s*{$", "if", r"}\s*else", "}")
elif re.match(selse, line.strip()): cond = None elif (line.strip() == send and cond != None and cond.find(sbegin) == line.find(send)): ip = next_block(lines, i, cond) if ip >= 0: lines = lines[:i] + lines[i+1:ip] + lines[ip+1:] continue
i += 1 continue m = re.match(selse, line) if m: if cond and m.start(1) <= cond.find(sbegin): cond = None i += 1 continue if line.strip() == send and (cond and cond.find(sbegin) >= line.find(send) ): if cond != None and cond.find(sbegin) == line.find(send): ip = next_block(lines, i, cond) if ip >= 0: lines = line...
def merge_blocks(lines, pattern, sbegin, selse, send): cond = None i = 1 while i < len(lines): line = lines[i] m = re.match(pattern, line.strip()) if m: #print "i:%4d, %s" % (i, line); raw_input() if not cond: cond = line elif re.match(selse, line.strip()): cond = None elif (line.strip() == send and cond != None and co...
debug(' adding executable: ' + exe_name)
debug(' adding executable: %s (%s)' % (exe_name, real_path))
def create_sfx(sfx_path, executables, libraries, data, environments, command): """ Create self-extracting executable Directory structure: bin Executables lib Libraries env Environment Scripts (static) run.sh Script that contains command """ tmp_file = NamedTemporaryFile(delete = False) tm...
debug(' adding library: ' + lib_name)
debug(' adding library: %s (%s)' % (lib_name, real_path))
def create_sfx(sfx_path, executables, libraries, data, environments, command): """ Create self-extracting executable Directory structure: bin Executables lib Libraries env Environment Scripts (static) run.sh Script that contains command """ tmp_file = NamedTemporaryFile(delete = False) tm...
debug(' adding environment script: ' + env_path)
debug(' adding environment script: %s (%s)' % (env_name, real_path))
def create_sfx(sfx_path, executables, libraries, data, environments, command): """ Create self-extracting executable Directory structure: bin Executables lib Libraries env Environment Scripts (static) run.sh Script that contains command """ tmp_file = NamedTemporaryFile(delete = False) tm...
debug(' adding data: ' + data_path)
debug(' adding data: %s (%s)' % (data_path, real_path))
def add_data_to_archive(archive, data_path, real_path): if os.path.isdir(real_path): for root, dirs, files in os.walk(real_path): for n in files + dirs: dp = os.path.join(root.replace(real_path, data_path), n) rp = os.path.join(root, n) add_data_to_archive(archive, dp, rp) else: data_info = archive.gettarinfo(os.path.r...
continue
break
def find_files(files, env_var): paths = ['.'] if env_var in os.environ: paths.extend(os.environ[env_var].split(':')) for file in files: for path in paths: file_path = os.path.join(path, file) if os.path.exists(file_path): yield file_path, os.path.realpath(file_path) continue raise StopIteration
path.extend(os.environ[env_var].split(':'))
paths.extend(os.environ[env_var].split(':'))
def find_files(files, env_var): paths = ['.'] if env_var in os.environ: path.extend(os.environ[env_var].split(':')) for file in files: for path in paths: file_path = path_join(path, file) if os.path.exists(file_path): yield file_path, realpath(file_path) continue raise StopIteration
return "No corresponding geographic location could be found for the " \ "specified location, possibly because the address is relatively " \ "new, or because it may be incorrect."
return 'null'
def __call__(self, address = None): try: locations = self.geocoder.retrieve(address) except GQueryError: return "No corresponding geographic location could be found for the " \ "specified location, possibly because the address is relatively " \ "new, or because it may be incorrect."
os.mkdir(_outdir)
def setup(): global _tempdir, _srcdir, _outdir _tempdir = tempfile.mkdtemp() _srcdir = os.path.join(_tempdir, 'src') _outdir = os.path.join(_tempdir, 'out') os.mkdir(_srcdir) os.mkdir(_outdir)
runsphinx(src, builder, confoverrides)
os.mkdir(_outdir)
def test(): src = '\n'.join(l[4:] for l in func.__doc__.splitlines()[2:]) runsphinx(src, builder, confoverrides) try: func() finally: os.unlink(os.path.join(_srcdir, 'index.rst'))
uid = self.request.get('uid', None) if uid is None: raise uid = uid.replace('uid_', '') obj = self.context.reference_catalog.lookupObject(uid)
favid = self.request.get('id', None) if favid is None: raise Exception('"id" not found in request')
def __call__(self, *args, **kwargs):
favFolder.manage_delObjects([obj.id, ])
favFolder.manage_delObjects([favid, ])
def __call__(self, *args, **kwargs):
config.set_hd_protection(self.protect.get_active())
config.set_floppy_protection(self.protect.get_active())
def run(self, config): "run(config), show disk image dialog" if not self.dialog: self._create_dialog(config) response = self.dialog.run() self.dialog.hide() if response == gtk.RESPONSE_APPLY: config.lock_updates() for drive in range(2): config.set_floppy(drive, self.floppy[drive].get_filename()) config.set_hd_protecti...
if self.get_borders(): width += self.get("[Screen]", "nWindowBorderPixelsLeft") width += self.get("[Screen]", "nWindowBorderPixelsRight") height += self.get("[Screen]", "nWindowBorderPixelsTop") height += self.get("[Screen]", "nWindowBorderPixelsBottom")
def get_window_size(self): if self.get("[Screen]", "bFullScreen"): print "WARNING: don't start Hatari UI with fullscreened Hatari!"
height += 12
sbar = 12 height += sbar else: sbar = 0
def get_window_size(self): if self.get("[Screen]", "bFullScreen"): print "WARNING: don't start Hatari UI with fullscreened Hatari!"
if 2*width < maxw and 2*height < maxh:
if 2*width <= maxw and 2*height <= maxh:
def get_window_size(self): if self.get("[Screen]", "bFullScreen"): print "WARNING: don't start Hatari UI with fullscreened Hatari!"
yield(act.get_name(), act.get_property("tooltip"))
note = act.get_property("tooltip") if not note: note = act.get_property("label") yield(act.get_name(), note)
def list_actions(self): yield ("|", "Separator between controls") yield (">", "Next toolbar in panel windows") # generate the list from action information for act in self.actions.list_actions(): yield(act.get_name(), act.get_property("tooltip")) yield ("<panel name>", "Button for the specified panel window") yield ("<n...
print "\nAvailable (toolbar) controls:"
print "\nAvailable (panel/toolbar) controls:"
def usage(actions, msg=None): name = os.path.basename(sys.argv[0]) uiname = "%s %s" % (UInfo.name, UInfo.version) print "\n%s" % uiname print "=" * len(uiname) print "\nUsage: %s [options] [floppy image]" % name print "\nOptions:" print "\t-h, --help\t\tthis help" print "\t-n, --nomenu\t\tomit menus" print "\t-e, --emb...
Hatari-console allows you to invoke Hatari remote configuration facilities from console while Hatari is running and use TAB completion on their names. The supported facilities are:"""
Hatari-console allows you to control Hatari through its control socket from the provided console prompt, while Hatari is running. All control commands support TAB completion on their names and options. The supported control facilities are:"""
def show_help(): print """
and for debugger with "h". Some other facilities may give help if you give them invalid input.
and for debugger with "help". Some other facilities may give help if you give them invalid input.
def show_help(): print """
hatari = Hatari(args[1:])
hatari = Hatari(args)
def __init__(self): args, self.file, self.exit = self.parse_args(sys.argv) hatari = Hatari(args[1:]) self.tokens = Tokens(hatari) self.command = CommandInput(self.tokens.get_tokens())
return (args, file, exit)
return (args[1:], file, exit)
def parse_args(self, args): if "-h" in args or "--help" in args: self.usage()
def run(self):
def loop(self):
def run(self): print """
Main().run()
Main().loop()
def run(self): print """
table, self.dialog = create_table_dialog(parent, "Debugger UI options", 1, 2) self.lines = table_add_entry_row(table, 0, "Memdump/disasm lines:", 2) self.lines.connect("activate", dialog_apply_cb, self.dialog) def run(self, lines): "run(lines) -> lines, as integers" self.lines.set_text(str(lines))
self.dialog = gtk.Dialog("Debugger UI options", parent, gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT, (gtk.STOCK_APPLY, gtk.RESPONSE_APPLY, gtk.STOCK_CLOSE, gtk.RESPONSE_CLOSE)) self.lines = gtk.Adjustment(0, 5, 50) scale = gtk.HScale(self.lines) scale.set_digits(0) self.follow_pc = gtk.CheckButton("On stop, se...
def __init__(self, parent): table, self.dialog = create_table_dialog(parent, "Debugger UI options", 1, 2) self.lines = table_add_entry_row(table, 0, "Memdump/disasm lines:", 2) self.lines.connect("activate", dialog_apply_cb, self.dialog)
while 1: lines = None response = self.dialog.run() if response == gtk.RESPONSE_APPLY: text = self.lines.get_text() if text: try: lines = int(text) except ValueError: ErrorDialog(self.dialog).run("lines needs an integer number") continue break else: ErrorDialog(self.dialog).run("please fill the field(s)") else: break
response = self.dialog.run() if response == gtk.RESPONSE_APPLY: lines = int(self.lines.get_value()) follow_pc = self.follow_pc.get_active()
def run(self, lines): "run(lines) -> lines, as integers" self.lines.set_text(str(lines)) self.dialog.show_all() while 1: lines = None response = self.dialog.run() if response == gtk.RESPONSE_APPLY: text = self.lines.get_text() if text: try: lines = int(text) except ValueError: ErrorDialog(self.dialog).run("lines needs ...
return lines
return (lines, follow_pc)
def run(self, lines): "run(lines) -> lines, as integers" self.lines.set_text(str(lines)) self.dialog.show_all() while 1: lines = None response = self.dialog.run() if response == gtk.RESPONSE_APPLY: text = self.lines.get_text() if text: try: lines = int(text) except ValueError: ErrorDialog(self.dialog).run("lines needs ...
self.first = None
if self.follow_pc: self.first = None
def clear(self): self.first = None self.second = None self.last = None
if not address: address = self.first
def dump(self, address = None, move_idx = 0): if not address: address = self.first if self.dumpmode == Constants.REGISTERS: output = self._get_registers() self.memory.set_label("".join(output)) return if not address: print "ERROR: address needed" return if self.dumpmode == Constants.MEMDUMP: output = self._get_memdu...
if not address: if not self.first: self._get_registers() address = self.first
def dump(self, address = None, move_idx = 0): if not address: address = self.first if self.dumpmode == Constants.REGISTERS: output = self._get_registers() self.memory.set_label("".join(output)) return if not address: print "ERROR: address needed" return if self.dumpmode == Constants.MEMDUMP: output = self._get_memdu...
lines = self.dialog_options.run(self.config.get("[General]", "nLines")) if lines:
old_lines = self.config.get("[General]", "nLines") old_follow_pc = self.config.get("[General]", "bFollowPC") lines, follow_pc = self.dialog_options.run(old_lines, old_follow_pc) if lines != old_lines:
def options_cb(self, widget): if not self.dialog_options: self.dialog_options = OptionsDialog(self.window) lines = self.dialog_options.run(self.config.get("[General]", "nLines")) if lines: self.config.set("[General]", "nLines", lines) self.address.set_lines(lines)
defaults = { "[General]": {"nLines": lines} }
defaults = { "[General]": { "nLines": lines, "bFollowPC": follow_pc } }
def load_options(self): # TODO: move config to MemoryAddress class? # (depends on how monitoring of addresses should work) lines = self.address.get_lines() miss_is_error = False # needed for adding windows defaults = { "[General]": {"nLines": lines} } userconfdir = ".hatari" config = ConfigStore(userconfdir, defaults, ...
config.load(config.get_filepath("debugui.cfg")) self.address.set_lines(config.get("[General]", "nLines"))
configpath = config.get_filepath("debugui.cfg") config.load(configpath) try: self.address.set_lines(config.get("[General]", "nLines")) self.address.set_follow_pc(config.get("[General]", "bFollowPC")) except (KeyError, AttributeError): ErrorDialog(None).run("Debug UI configuration mismatch!\nTry again after removing: '%...
def load_options(self): # TODO: move config to MemoryAddress class? # (depends on how monitoring of addresses should work) lines = self.address.get_lines() miss_is_error = False # needed for adding windows defaults = { "[General]": {"nLines": lines} } userconfdir = ".hatari" config = ConfigStore(userconfdir, defaults, ...
class FselAndEjectFactory():
class FselAndEjectFactory:
def get_save_filename(title, parent, path = None): buttons = (gtk.STOCK_OK, gtk.RESPONSE_OK, gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL) fsel = gtk.FileChooserDialog(title, parent, gtk.FILE_CHOOSER_ACTION_SAVE, buttons) fsel.set_local_only(True) fsel.set_do_overwrite_confirmation(True) if path: fsel.set_filename(path) if no...
class FselEntry():
class FselEntry:
def _eject(self, widget, fsel): fsel.unselect_all()
print "->", msg
if self.verbose: print "-> '%s'" % msg
def send_message(self, msg): if self.control: print "->", msg self.control.sendall(msg + "\n") # KLUDGE: wait so that Hatari output comes before next prompt time.sleep(0.2) return True else: print "ERROR: no Hatari (control socket)" return False
def pause(self):
def set_pause(self):
def pause(self): return self.send_message("hatari-stop")
def unpause(self):
def set_unpause(self):
def unpause(self): return self.send_message("hatari-cont")
def stop(self):
def set_stop(self):
def stop(self): if self.pid: os.kill(self.pid, signal.SIGKILL) print "killed hatari with PID %d" % self.pid self.control = None self.pid = 0
"rightpress", "rightrelease",
"rightdown", "rightup",
def loop(self): try: rawline = raw_input(self.prompt) return rawline except EOFError: return ""
"keyrelease"
"keydown", "keyup", "text"
def loop(self): try: rawline = raw_input(self.prompt) return rawline except EOFError: return ""
"pause": hatari.pause, "unpause": hatari.unpause, "quit": hatari.stop
"pause": hatari.set_pause, "unpause": hatari.set_unpause, "verbose": hatari.set_verbose, "quit": hatari.set_stop
def __init__(self, hatari): self.process_tokens = { "console-help": self.show_help, "pause": hatari.pause, "unpause": hatari.unpause, "quit": hatari.stop } self.hatari = hatari
hatari = Hatari(args)
hatari = Hatari(args[1:])
def __init__(self): args, self.file, self.exit = self.parse_args(sys.argv) hatari = Hatari(args) self.tokens = Tokens(hatari) self.command = CommandInput(self.tokens.get_tokens())
%s --monitor mono
%s --monitor mono test.prg
def usage(self, msg=None): name = os.path.basename(sys.argv[0]) print "\n%s" % name print "=" * len(name) print """
app_name = gobject.get_application_name() self.set_title(_('About %s') % app_name)
self.set_title(_('About'))
def __init__(self): gtk.Dialog.__init__(self)
self.update_feed_cache(channels=[self.active_channel])
if getattr(self.active_channel, 'ALL_EPISODES_PROXY', False): self.update_feed_cache() else: self.update_feed_cache(channels=[self.active_channel])
def on_itemUpdateChannel_activate(self, widget=None): if self.active_channel is None: title = _('No podcast selected') message = _('Please select a podcast in the podcasts list to update.') self.show_message( message, title, widget=self.treeChannels) return
self.itemEditChannel.set_visible(True) self.itemRemoveChannel.set_visible(True)
if getattr(self.active_channel, 'ALL_EPISODES_PROXY', False): self.itemEditChannel.set_visible(False) self.itemRemoveChannel.set_visible(False) else: self.itemEditChannel.set_visible(True) self.itemRemoveChannel.set_visible(True)
def on_treeChannels_cursor_changed(self, widget, *args): ( model, iter ) = self.treeChannels.get_selection().get_selected()
_('%(position)d/%(total)d updated') % {'position': updated, 'total': total})
_('%(position)d/%(total)d updated') % {'position': updated+1, 'total': total})
def update_feed_cache_proc(self, channels, select_url_afterwards): total = len(channels)
self.update_podcast_list_model(selected=True)
def on_selected_episodes_status_changed(self): self.update_episode_list_icons(selected=True) self.update_podcast_list_model(selected=True) self.db.commit()
episode = model.get_value(model.get_iter(path), EpisodeListModel.C_EPISODE)
try: episode = model.get_value(model.get_iter(path), EpisodeListModel.C_EPISODE) except TypeError, te: log('Invalid episode at path %s', str(path), sender=self) continue
def play_or_download(self): if not gpodder.ui.fremantle: if self.wNotebook.get_current_page() > 0: if gpodder.ui.desktop: self.toolCancel.set_sensitive(True) return
adjustment_update_interval.set_upper(len(self.update_interval_presets)-1)
adjustment_update_interval.upper = len(self.update_interval_presets)-1
def new(self): if not hasattr(self, 'callback_finished'): self.callback_finished = None
adjustment_expiration.set_upper(self._config.episode_old_age)
adjustment_expiration.upper = self._config.episode_old_age
def new(self): if not hasattr(self, 'callback_finished'): self.callback_finished = None
log("sending " + filename + " (" + episode.title + ").", sender=self)
log("sending %s (%s).", filename, episode.title, sender=self)
def add_track(self, episode): self.notify('status', _('Adding %s...') % episode.title) filename = str(self.convert_track(episode)) log("sending " + filename + " (" + episode.title + ").", sender=self)
count = len(episodes) if count == 1: episode = episodes[0] if episode.is_locked: title = _('%s is locked') % saxutils.escape(episode.title) message = _('You cannot delete this locked episode. You must unlock it before you can delete it.') self.notification(message, title, widget=self.treeAvailable) return False title...
episodes = [e for e in episodes if not e.is_locked] if not episodes:
def delete_episode_list(self, episodes, confirm=True): if not episodes: return False
elif locked_count > 0: title = _('Remove %(unlocked)d out of %(selected)d episodes?') % {'unlocked': count-locked_count, 'selected': count} message = _('The selection contains locked episodes that will not be deleted. If you want to listen to the deleted episodes, you will have to re-download them.')
count = len(episodes) title = N_('Delete %d episode?', 'Delete %d episodes?', count) % count message = _('Deleting episodes removes downloaded files.') if gpodder.ui.fremantle: message = '\n'.join([title, message])
def delete_episode_list(self, episodes, confirm=True): if not episodes: return False
progress = ProgressIndicator(_('Removing episodes'), \
progress = ProgressIndicator(_('Deleting episodes'), \
def delete_episode_list(self, episodes, confirm=True): if not episodes: return False
gPodderEpisodeSelector(self.gPodder, title = _('Remove old episodes'), instructions = instructions, \
gPodderEpisodeSelector(self.gPodder, title = _('Delete old episodes'), instructions = instructions, \
def on_itemRemoveOldEpisodes_activate( self, widget): if gpodder.ui.maemo: columns = ( ('maemo_remove_markup', None, None, _('Episode')), ) else: columns = ( ('title_markup', None, None, _('Episode')), ('filesize_prop', 'length', gobject.TYPE_INT, _('Size')), ('pubdate_prop', 'pubDate', gobject.TYPE_INT, _('Released'))...
entries = feed.entries[:max_episodes]
try: entries = sorted(feed.entries, \ key=lambda x: x.get('updated_parsed', (0,)*9), \ reverse=True)[:max_episodes] except Exception, e: log('Could not sort episodes: %s', e, sender=self, traceback=True) entries = feed.entries[:max_episodes]
def _consume_updated_feed(self, feed, max_episodes=0, mimetype_prefs=''): self.parse_error = feed.get('bozo_exception', None)
dbus_bus_name = 'org.godder'
dbus_bus_name = 'org.gpodder'
def maemo(self): return self.diablo or self.fremantle
scroll.set_name(widget.get_name())
scroll.set_name(gtk.Buildable.get_name(widget))
def create_fingerscroll(): if mokoui is not None: scroll = mokoui.FingerScroll() scroll.set_property('mode', 0) scroll.set_property('spring-speed', 0) scroll.set_property('deceleration', .975) else: scroll = hildon.PannableArea() scroll.set_name(widget.get_name()) return scroll
widget_name = widget.get_name()
widget_name = gtk.Buildable.get_name(widget)
def set_attributes(self): """ Convert widget names to attributes of this object.
tooltip.append(_('never played'))
if file_type == 'image': tooltip.append(_('never displayed')) else: tooltip.append(_('never played'))
def update_by_iter(self, iter, downloading=None, include_description=False): episode = self.get_value(iter, self.C_EPISODE) episode.reload_from_db()
tooltip.append(_('played'))
if file_type == 'image': tooltip.append(_('displayed')) else: tooltip.append(_('played'))
def update_by_iter(self, iter, downloading=None, include_description=False): episode = self.get_value(iter, self.C_EPISODE) episode.reload_from_db()
except ProgrammingError, e:
except Exception, e:
def commit(self): self.lock.acquire() try: self.log("COMMIT") self.db.commit() except ProgrammingError, e: log('Error commiting changes: %s', e, sender=self, traceback=True) self.lock.release()
if url is None and channel.url.startswith("http://"): url = "http://" + channel.link[7:].split("/")[0] + "/favicon.ico"
if url is None and channel.link is not None and \ channel.link.startswith('http://'): split_result = urlparse.urlsplit(channel.link) scheme, netloc, path, query, fragment = split_result path = '/favicon.ico' query = '' split_result = (scheme, netloc, path, query, fragment) url = urlparse.urlunsplit(split_result) log('...
def __get_cover(self, channel, url, async=False, avoid_downloading=False): if not async and avoid_downloading and not os.path.exists(channel.cover_file): return (channel.url, None)
can_delete = True
def play_or_download(self): if not gpodder.ui.fremantle: if self.wNotebook.get_current_page() > 0: if gpodder.ui.desktop: self.toolCancel.set_sensitive(True) return
self.itemDeleteSelected.set_sensitive(can_play and not can_download)
self.itemDeleteSelected.set_sensitive(can_delete or not can_cancel)
def play_or_download(self): if not gpodder.ui.fremantle: if self.wNotebook.get_current_page() > 0: if gpodder.ui.desktop: self.toolCancel.set_sensitive(True) return
service, path = 'com.nokia.mediaplayer', '/com/nokia/mediaplayer' rpc.rpc_run(service, path, service, 'mime_open', (filename,))
app = 'mediaplayer' _unneeded, extension = os.path.splitext(filename.lower()) if extension == '.pdf': app = 'osso_pdfviewer' elif extension in ('.jpg', '.jpeg', '.png'): app = 'image_viewer' svc, path = (x % app for x in ('com.nokia.%s', '/com/nokia/%s')) rpc.rpc_run(svc, path, svc, 'mime_open', (filename,))
def gui_open(filename): """ Open a file or folder with the default application set by the Desktop environment. This uses "xdg-open" on all systems with a few exceptions: on Win32, os.startfile() is used on Maemo, osso is used to communicate with Nokia Media Player """ try: if gpodder.ui.maemo: try: import osso except ...
self.apply_fixes()
def __init__(self, filename='gpodder.conf'): dict.__init__(self) self.__save_thread = None self.__filename = filename self.__section = 'gpodder-conf-1' self.__observers = []
def apply_fixes(self): if '{channel' in self.custom_sync_name: log('Fixing OLD syntax {channel.*} => {podcast.*} in custom_sync_name.', sender=self) self.custom_sync_name = self.custom_sync_name.replace('{channel.', '{podcast.')
def apply_fixes(self): # Here you can add fixes in case syntax changes. These will be # applied whenever a configuration file is loaded. if '{channel' in self.custom_sync_name: log('Fixing OLD syntax {channel.*} => {podcast.*} in custom_sync_name.', sender=self) self.custom_sync_name = self.custom_sync_name.replace('{c...
return self.result / gst.MSECOND
if self.result is not None: return self.result / gst.MSECOND else: return None
def run(self, filename): gobject.idle_add(self.on_idle, filename) self.mainloop.run() return self.result / gst.MSECOND
size = int(headers["Content-Length"]) + current_size
size = int(headers.getrawheader("Content-Length")) + current_size
def retrieve_resume(self, url, filename, reporthook=None, data=None): """Download files from an URL; return (headers, real_url)
cover_loc = os.path.join(os.path.dirname(local_filename), 'cover') if not os.path.exists(cover_loc): cover_loc = os.path.join(os.path.dirname(local_filename), '.cover')
cover_loc = os.path.join(os.path.dirname(local_filename), 'folder.jpg')
def copy_player_cover_art(self, destination, local_filename, \ cover_dst_name, cover_dst_format, \ cover_dst_size): """ Try to copy the channel cover to the podcast folder on the MP3 player. This makes the player, e.g. Rockbox (rockbox.org), display the cover art in its interface.
dependency_manager.depend_on(_('Bluetooth file transfer'), _('Send podcast episodes to Bluetooth devices. Needs Python Bluez bindings.'), ['bluetooth'], ['bluetooth-sendto'])
dependency_manager.depend_on(_('Bluetooth file transfer'), _('Send podcast episodes to Bluetooth devices. Needs the bluetooth-sendto command from gnome-bluetooth.'), ['bluetooth'], ['bluetooth-sendto'])
def tools_available(self, tools): """ See modules_available. """ result = {} all_available = True for tool in tools: if util.find_command(tool): result[tool] = True else: result[tool] = False all_available = False
util.open_website('http://wiki.gpodder.org/')
util.open_website('http://gpodder.org/wiki/User_Manual')
def on_wiki_activate(self, widget, *args): util.open_website('http://wiki.gpodder.org/')