rem stringlengths 0 322k | add stringlengths 0 2.05M | context stringlengths 8 228k |
|---|---|---|
return task.get_status() == self.STA_ACTIVE | return task.get_status() == Task.STA_ACTIVE | def active(self,task): """ Filter of tasks which are active """ #FIXME: we should also handle unactive tags return task.get_status() == self.STA_ACTIVE |
return task.get_status() in [self.STA_DISMISSED,self.STA_DONE] | return task.get_status() in [Task.STA_DISMISSED, Task.STA_DONE] | def closed(self,task): """ Filter of tasks which are closed """ return task.get_status() in [self.STA_DISMISSED,self.STA_DONE] |
if self.logger: self.logger.debug ("rtm task has no title") | self.__log("rtm task has no title: " + str(self.task)) | def _get_title(self): if hasattr(self.task,"name"): return self.task.name else: if self.logger: self.logger.debug ("rtm task has no title") return "" |
if type(self.task.task) == type(list): return getattr(self.task.task[0], attr) else: | if hasattr(self.task.task, 'list'): self.__log("getting a rtm task attribute(1): " + \ str(self.task.task)) return getattr(self.task.task.list, attr) else: self.__log("getting a rtm task attribute(2): " + \ str(self.task.task)) | def __get_rtm_task_attribute(self, attr): if hasattr(self.task, 'task'): if type(self.task.task) == type(list): return getattr(self.task.task[0], attr) else: return getattr(self.task.task, attr) else: return getattr(self.task, attr) |
You can also create a task with attributes like tags, due date or defer date in the quickadd entry. For that the syntax is : | def populate(): doc,root = cleanxml.emptydoc("project") #Task 0@1: Getting started with GTG title1 = _("Getting started with GTG") text1 = _("""Welcome to Getting Things Gnome!, your new task manager. | |
tags:tag1,tag2,tag3 : This way you can apply as many tags as you wish using comma as separator | You can also create a task with the attributes "tags", "due", and "defer" in the quickadd entry. The syntax for these attributes is: | def populate(): doc,root = cleanxml.emptydoc("project") #Task 0@1: Getting started with GTG title1 = _("Getting started with GTG") text1 = _("""Welcome to Getting Things Gnome!, your new task manager. |
due:date or defer:date : This way you can apply a due date or a defer date. date can be yyyy-mm-dd (for example 2009-04-01) or yyyymmdd (20090401) or mmdd (0401, in this case the year is implicitly the current one) or today or tomorrow or a weekday name (due:monday means due next Monday) | tags:tag1,tag2,tag3 - This way you can apply as many tags as you wish using comma as separator due:date defer:date - This way you can apply a due date or a defer date. date can be yyyy-mm-dd (for example 2009-04-01) or yyyymmdd (20090401) or mmdd (0401, in this case the year is implicitly the current one) or today or ... | def populate(): doc,root = cleanxml.emptydoc("project") #Task 0@1: Getting started with GTG title1 = _("Getting started with GTG") text1 = _("""Welcome to Getting Things Gnome!, your new task manager. |
hamster_id=self.hamster.AddFact('%s%s,%s%s'%(activity, category, description, tag_str), 0, 0) | def sendTask(self, task): """Send a gtg task to hamster-applet""" if task is None: return gtg_title = task.get_title() gtg_tags = tags=[t.lstrip('@').lower() for t in task.get_tags_name()] activity = "Other" if self.preferences['activity'] == 'tag': hamster_activities=set([unicode(x[0]).lower() for x in self.hamster.G... | |
ids.append(str(hamster_id)) | try: hamster_id=self.hamster.AddFact('%s%s,%s%s'%(activity, category, description, tag_str), 0, 0) ids.append(str(hamster_id)) except dbus.exceptions.DBusException: pass | def sendTask(self, task): """Send a gtg task to hamster-applet""" if task is None: return gtg_title = task.get_title() gtg_tags = tags=[t.lstrip('@').lower() for t in task.get_tags_name()] activity = "Other" if self.preferences['activity'] == 'tag': hamster_activities=set([unicode(x[0]).lower() for x in self.hamster.G... |
self.__model.add_task(None,deleted.get_id()) | def get(self,node,path): key = self.__key(node,path) toreturn = None deleted = False if node and self.__store.has_key(key): stored_iter = self.__store[key] stored_node = stored_iter.get_node() if stored_node == node: toreturn = stored_iter elif stored_node: print "path %s is now %s (and it was %s)" %(str(path),node.get... | |
self.tree.add_node(node, parent_id = '0') | self.assertSignal(self.view, \ 'node-modified-inview', \ self.tree.add_node, 2)(node, parent_id = '0') self.assert_(('temp',) in self.recorded_signals['node-modified-inview']) self.assert_(('0',) in self.recorded_signals['node-modified-inview']) | def test_add_parent(self): view = self.tree.get_viewtree(refresh = True) node = DummyNode('temp') node.add_color('blue') |
"on_defer_to_tomorrow": self.on_defer_to_tomorrow, "on_defer_to_next_week": self.on_defer_to_next_week, "on_defer_to_next_month": self.on_defer_to_next_month, "on_defer_to_next_year": self.on_defer_to_next_year, | "on_schedule_for_tomorrow": self.on_schedule_for_tomorrow, "on_schedule_for_next_week": self.on_schedule_for_next_week, "on_schedule_for_next_month": self.on_schedule_for_next_month, "on_schedule_for_next_year": self.on_schedule_for_next_year, | def _init_signal_connections(self): |
def on_defer_to_tomorrow(self, widget): | def on_schedule_for_tomorrow(self, widget): | def on_defer_to_tomorrow(self, widget): self.update_start_date(widget, "tomorrow") |
def on_defer_to_next_week(self, widget): | def on_schedule_for_next_week(self, widget): | def on_defer_to_next_week(self, widget): self.update_start_date(widget, "next week") |
def on_defer_to_next_month(self, widget): | def on_schedule_for_next_month(self, widget): | def on_defer_to_next_month(self, widget): self.update_start_date(widget, "next month") |
def on_defer_to_next_year(self, widget): | def on_schedule_for_next_year(self, widget): | def on_defer_to_next_year(self, widget): self.update_start_date(widget, "next year") |
for task in self.tasks: if self.req.get_task(task).get_status() == "Active": | for tid in self.tasks: task = self.req.get_task(tid) if task and task.get_status() == "Active": | def is_actively_used(self): toreturn = False for task in self.tasks: if self.req.get_task(task).get_status() == "Active": toreturn = True return toreturn |
if cid in self.virtual_root: print "*** children %s of task %s is also in VR" \ %(cid,node.get_id()) print " we will correct that error now" self.__root_update(cid,False) | def node_nth_child(self, node, n): """ Retrieves the nth child of the node. @param node: The parent node, or None to look at children of the virtual_root. """ #we return the nth good children ! if not node: if len(self.virtual_root) > n: to_id = self.virtual_root[n] toreturn = self.get_node(to_id) | |
if not self.flat: node = self.get_node(tid) nc = self.node_n_children(node) i = 0 while i < nc: ch = self.node_nth_child(node,i) chid = ch.get_id() if chid in self.virtual_root: self.__root_update(chid,False) i += 1 | children_update = True | def __root_update(self,tid,inroot): if inroot: if tid not in self.virtual_root: self.virtual_root.append(tid) #We will also update the children of that node if not self.flat: node = self.get_node(tid) nc = self.node_n_children(node) i = 0 while i < nc: ch = self.node_nth_child(node,i) chid = ch.get_id() if chid in self... |
else: children_update = True if not self.flat and children_update: node = self.get_node(tid) nc = self.node_n_children(node) if tid in DEBUG_TID: print "updating %s childrens of node %s" %(nc,tid) i = 0 while i < nc: ch = self.node_nth_child(node,i) chid = ch.get_id() if chid in self.virtual_root: if tid in DEBUG_TI... | def __root_update(self,tid,inroot): if inroot: if tid not in self.virtual_root: self.virtual_root.append(tid) #We will also update the children of that node if not self.flat: node = self.get_node(tid) nc = self.node_n_children(node) i = 0 while i < nc: ch = self.node_nth_child(node,i) chid = ch.get_id() if chid in self... | |
class ActiveTaskTreeView(TaskTreeView): """TreeView for display of a list of task. Handles DnD primitives too.""" DND_TARGETS = [ ('gtg/task-iter-str', gtk.TARGET_SAME_WIDGET, 0) ] def __init__(self, requester): TaskTreeView.__init__(self, requester) self._init_tree_view() self.get_selection().set_mode(gtk.SELECTION_... | def set_column(self,index,col): self.__columns[index] = col | |
print "*** iter %s" %iter | def on_drag_data_received(self, treeview, context, x, y, selection, info,\ timestamp): model = treeview.get_model() tasktree_model = model.get_model() drop_info = treeview.get_dest_row_at_pos(x, y) if drop_info: path, position = drop_info iter = model.get_iter(path) # Must add the task to the parent of the tas... | |
self.__root_update(curn,False) | self.__root_update(cid,False) | def node_nth_child(self, node, n): """ Retrieves the nth child of the node. @param node: The parent node, or None to look at children of the virtual_root. """ #we return the nth good children ! if not node: if len(self.virtual_root) > n: to_id = self.virtual_root[n] toreturn = self.get_node(to_id) |
parent = tag.get_attribute('parent') if parent: pnode=self.new_tag(parent) tag.set_parent(pnode) | def __init__(self,requester): Tree.__init__(self) self.req = requester ### building the initial tags # Build the "all tasks tag" self.alltag_tag = self.new_tag("gtg-tags-all") self.alltag_tag.set_attribute("special","all") self.alltag_tag.set_attribute("label","<span weight='bold'>%s</span>"\ % _("All tasks")) self.al... | |
attr = t.get_all_attributes(butname=True) | attr = t.get_all_attributes(butname = True, withparent = True) | def save(self): doc, xmlroot = cleanxml.emptydoc(XMLROOT) tags = self.get_all_tags() already_saved = [] #We avoid saving the same tag twice #we don't save tags with no attributes #It saves space and allow the saved list growth to be controlled for t in tags: attr = t.get_all_attributes(butname=True) if "special" in att... |
def get_all_attributes(self, butname=False): | def get_all_attributes(self, butname=False, withparent = False): | def get_all_attributes(self, butname=False): """Return a list of all attribute names. |
if self.__updating_lock.acquire(False) \ and len(self.__updating_queue) > 0: | if self.__updating_lock.acquire(False): | def external_update_node(self,tid): if not tid: raise ValueError('cannot update node None') if self.__initialized: self.__updating_queue.append([tid,'update']) if self.__updating_lock.acquire(False) \ and len(self.__updating_queue) > 0: self.__execution_loop() |
if self.__updating_lock.acquire(False)\ and len(self.__updating_queue) > 0: | if self.__updating_lock.acquire(False): | def external_add_node(self,tid): if not tid: raise ValueError('cannot add node None') if self.__initialized: self.__updating_queue.append([tid,'add']) if self.__updating_lock.acquire(False)\ and len(self.__updating_queue) > 0: self.__execution_loop() |
if self.__updating_lock.acquire(False)\ and len(self.__updating_queue) > 0: | if self.__updating_lock.acquire(False): | def external_remove_node(self,tid): if not tid: raise ValueError('cannot remove node None') if self.__initialized: self.__updating_queue.append([tid,'delete']) if self.__updating_lock.acquire(False)\ and len(self.__updating_queue) > 0: self.__execution_loop() |
elif typ == "http" : openurl.openurl(anchor) | elif typ == "http": if button == 1: openurl.openurl(anchor) | def _tag_event(self, tag, view, ev, _iter, text, anchor,typ): #pylint: disable-msg=W0613 _type = ev.type if _type == gtk.gdk.MOTION_NOTIFY: return elif _type in [gtk.gdk.BUTTON_PRESS, gtk.gdk.BUTTON_RELEASE]: button = ev.button cursor = gtk.gdk.Cursor(gtk.gdk.HAND2) if _type == gtk.gdk.BUTTON_RELEASE: if typ == "subtas... |
fp.write(dom.toxml()) | fp.write(dom.toxml().encode("utf8")) | def anonymize(filename, outputfile): try: dom = parse(filename) except Exception, err: print "error while parsing %s: %s" % (filename, err) return tasks = dom.getElementsByTagName("task") for task in tasks: textnode = task.getElementsByTagName("title")[0].childNodes[0] nodevalue = textnode.nodeValue newnodevalue = "... |
entry_text = [entry_text.strip()] if not entry_text[0]: error_message = "Please enter a tag name." addtag_error = True | def on_addtag_confirm(self, widget): tag_entry = self.builder.get_object("tag_entry") addtag_dialog = self.builder.get_object("addtag_dialog") apply_to_subtasks = self.builder.get_object("apply_to_subtasks") addtag_error = False entry_text = tag_entry.get_text() entry_text = [entry_text.strip()] # Set up a warning mess... | |
if "," in entry_text[0]: entry_text = entry_text[0].split(",") for tagname in entry_text: tagname = tagname.strip() if not addtag_error: if " " in tagname: error_message = "Tag name must not contain spaces." addtag_error = True break new_tags.append("@" + tagname) if addtag_error: error_dialog = gtk.MessageDialog(N... | for text in entry_text.split(","): tags = [t.strip() for t in text.split(" ")] for tag in tags: if tag: new_tags.append("@" + tag) | def on_addtag_confirm(self, widget): tag_entry = self.builder.get_object("tag_entry") addtag_dialog = self.builder.get_object("addtag_dialog") apply_to_subtasks = self.builder.get_object("apply_to_subtasks") addtag_error = False entry_text = tag_entry.get_text() entry_text = [entry_text.strip()] # Set up a warning mess... |
if len(my_word) > 1 and my_word[0] == '@': | if len(my_word) > 1 and my_word[0] == '@' \ and not my_word[1] == '@': | def _detect_tag(self,buff,start,end) : # Removing already existing tag in the current selection # out of the tag table it = start.copy() table = buff.get_tag_table() old_tags = [] new_tags = [] #We must be strictly < than the end_offset. If not, we might #find the beginning of a tag on the nextline while (it.get_offset... |
self.req.connect('task-added',self.update_tag_task_added) self.req.connect('task-deleted',self.update_tag_task_deleted) | self.req.connect('task-added',self.on_task_added) self.req.connect('task-deleted',self.on_task_deleted) self.req.connect('task-modified',self.on_task_modified) | def __init__(self, requester): gtk.GenericTreeModel.__init__(self) self.req = requester self.tree = self.req.get_tag_tree() self.workview = False |
def update_tags_for_task(self, tid): task = self.req.get_task(tid) | def update_tags_for_task(self, task_id): task = self.req.get_task(task_id) | def update_tags_for_task(self, tid): task = self.req.get_task(tid) if task: for t in task.get_tags(): path = self.tree.get_path_for_node(t) iter = self.get_iter(path) self.row_changed(path, iter) |
for t in task.get_tags(): path = self.tree.get_path_for_node(t) iter = self.get_iter(path) self.row_changed(path, iter) | for tag in task.get_tags(): tasks_count = tag.get_tasks_nbr(workview=self.workview) tag_name = tag.get_name() if tasks_count < 1: if tag_name in self.displayed: self.row_deleted(self.displayed[tag_name]) self.displayed.pop(tag_name) else: self._update_tag_from_name(tag_name) def _update_all_tasks_and_no_tags(self): ''... | def update_tags_for_task(self, tid): task = self.req.get_task(tid) if task: for t in task.get_tags(): path = self.tree.get_path_for_node(t) iter = self.get_iter(path) self.row_changed(path, iter) |
def update_tag_task_added(self, sender, task_id): | def on_task_added(self, sender, task_id): | def add_tag(self, sender, tname): Log.debug("add tag %s" % (tname)) |
self._update_tag_from_name(self.req.get_alltag_tag().get_name()) self._update_tag_from_name(self.req.get_notag_tag().get_name()) | def update_tag_task_added(self, sender, task_id): ''' This method handles the adding of tasks, updating the "All task" entry in the tag pane and the "No tags" ''' self._update_tag_from_name(self.req.get_alltag_tag().get_name()) self._update_tag_from_name(self.req.get_notag_tag().get_name()) task = self.req.get_task(tas... | |
self.update_tag(sender, tag.get_name()) def update_tag_task_deleted(self, sender, task_id): | self._update_tag_from_name(tag.get_name()) def on_task_deleted(self, sender, task_id): | def update_tag_task_added(self, sender, task_id): ''' This method handles the adding of tasks, updating the "All task" entry in the tag pane and the "No tags" ''' self._update_tag_from_name(self.req.get_alltag_tag().get_name()) self._update_tag_from_name(self.req.get_notag_tag().get_name()) task = self.req.get_task(tas... |
task = self.req.get_task(task_id) for tag in task.get_tags(): tasks_count = tag.get_tasks_nbr(workview=self.workview) if tasks_count <= 1: tag_name = tag.get_name() if tag_name in self.displayed: self.row_deleted(self.displayed[tag_name]) self.displayed.pop(tag_name) self._update_tag_from_name(self.req.get_alltag_tag()... | self._update_all_tasks_and_no_tags() self.update_tags_for_task(task_id) def on_task_modified(self, sender, task_id): ''' This method handles the modification of tasks ''' self.update_tags_for_task(task_id) | def update_tag_task_deleted(self, sender, task_id): ''' This method handles the deleting of tasks, updating the "All task" entry in the tag pane and the "No tags" ''' task = self.req.get_task(task_id) for tag in task.get_tags(): tasks_count = tag.get_tasks_nbr(workview=self.workview) if tasks_count <= 1: tag_name = tag... |
thread = threading.Thread(target = selecter, args = (treemodelsort, path, iter, self)) thread.setDaemon(True) thread.start() | gobject.idle_add(selecter,treemodelsort, path, iter, self) | def selecter(treemodelsort, path, iter, self): self.__last_quick_added_tid_event.wait() treeview = self.vtree_panes['active'] liblarch_path = treemodelsort.convert_path_to_child_path(path) tid = self.activetree.get_node_for_path(liblarch_path) if self.__last_quick_added_tid == tid: #this is the correct task treemodelso... |
return task.get_closed_date().to_readable_string() | return task.get_closed_date() | def on_get_value(self, node, column): |
print "WE WILL NOT ADD %s" %node.get_id() self.tasks_to_add.pop(node.get_id()) | self.tasks_to_add.remove(node.get_id()) | def on_get_iter(self, path): |
self.new_relationship(rel[0],rel[1]) | self.new_relationship(rel[0],rel[1],refresh_nodes=False) | def add_node(self, node, parent_id=None): id = node.get_id() if self.nodes.has_key(id): print "Error : A node with this id %s already exists" %id return False else: #We add the node node.set_tree(self) if not parent_id: parent_id = 'root' #we build the relationship before adding the node ! #That's crucial, else, the no... |
def new_relationship(self,parent_id,child_id): | def new_relationship(self,parent_id,child_id,refresh_nodes=True): | def new_relationship(self,parent_id,child_id): #Genealogic search is a function we use to build a list of every #ancestor of a node def genealogic_search(nid): if nid not in genealogy: genealogy.append(nid) if self.has_node(nid): node = self.get_node(nid) for par in node.get_parents(): genealogic_search(par) Log.debug(... |
if toreturn: | if refresh_nodes and toreturn: | def genealogic_search(nid): if nid not in genealogy: genealogy.append(nid) if self.has_node(nid): node = self.get_node(nid) for par in node.get_parents(): genealogic_search(par) |
task_tags = set([t.get_name() for t in task.get_tags()]) | task_tags = set(task.get_tags_name()) | def backend_filter(self, task, tags_to_match_set): ''' Filter that checks if two tags sets intersect. It is used to check if a task should be stored inside a backend @param task: a task object @oaram tags_to_match_set: a *set* of tag names ''' all_tasks_tag = self.req.get_alltag_tag().get_name() if all_tasks_tag in tag... |
text = self.quickadd_entry.get_text() | text = unicode(self.quickadd_entry.get_text()) | def on_quickadd_activate(self, widget): text = self.quickadd_entry.get_text() due_date = no_date defer_date = no_date if text: tags, notagonly = self.get_selected_tags() # Get tags in the title #NOTE: the ?: tells regexp that the first one is # a non-capturing group, so it must not be returned # to findall. http://www.... |
for match in re.findall(r'(?:^|[\s])(@\w+)', text): | for match in re.findall(r'(?:^|[\s])(@\w+)', text, re.UNICODE): | def on_quickadd_activate(self, widget): text = self.quickadd_entry.get_text() due_date = no_date defer_date = no_date if text: tags, notagonly = self.get_selected_tags() # Get tags in the title #NOTE: the ?: tells regexp that the first one is # a non-capturing group, so it must not be returned # to findall. http://www.... |
label_text = "Deleting a task cannot be undone, and will delete the following task: " cdlabel2.set_label("Are you sure you want to delete this task?") cdlabel3.set_label("Keep selected task") cdlabel4.set_label("Permanently remove task") | label_text = _("Deleting a task cannot be undone, and will delete the following task: ") cdlabel2.set_label(_("Are you sure you want to delete this task?")) cdlabel3.set_label(_("Keep selected task")) cdlabel4.set_label(_("Permanently remove task")) | def on_delete_task(self, widget=None, tid=None): #If we don't have a parameter, then take the selection in the treeview if not tid: #tid_to_delete is a [project,task] tuple self.tids_todelete = self.get_selected_tasks() else: self.tids_todelete = [tid] #We must at least have something to delete ! if len(self.tids_todel... |
label_text = "Deleting a task cannot be undone, and will delete the following tasks: " cdlabel2.set_label("Are you sure you want to delete these tasks?") cdlabel3.set_label("Keep selected tasks") cdlabel4.set_label("Permanently remove tasks") | label_text = _("Deleting a task cannot be undone, and will delete the following tasks: ") cdlabel2.set_label(_("Are you sure you want to delete these tasks?")) cdlabel3.set_label(_("Keep selected tasks")) cdlabel4.set_label(_("Permanently remove tasks")) | def on_delete_task(self, widget=None, tid=None): #If we don't have a parameter, then take the selection in the treeview if not tid: #tid_to_delete is a [project,task] tuple self.tids_todelete = self.get_selected_tasks() else: self.tids_todelete = [tid] #We must at least have something to delete ! if len(self.tids_todel... |
treeview.set_bg_color(self.task_bg_color,'tags') | def active_tasks_treeview(self,tree): desc = {} #invisible 'title' column col_name = 'title' col = {} render_text = gtk.CellRendererText() render_text.set_property("ellipsize", pango.ELLIPSIZE_END) col['renderer'] = ['markup',render_text] col['value'] = [str,self.task_title_column] col['visible'] = False col['order'] ... | |
return treeview | def active_tasks_treeview(self,tree): desc = {} #invisible 'title' column col_name = 'title' col = {} render_text = gtk.CellRendererText() render_text.set_property("ellipsize", pango.ELLIPSIZE_END) col['renderer'] = ['markup',render_text] col['value'] = [str,self.task_title_column] col['visible'] = False col['order'] ... | |
self.trace = '\nDEBUG TRACE for ViewTree %s\n----------------\n\n'%self | if DEBUG: self.trace = '\nDEBUG TRACE for ViewTree %s\n-------------\n\n'%self | def __init__(self,tree,filtersbank,refresh=True): """ Construct a FilteredTree object on top of an existing task tree. @param req: The requestor object @param tree: The tree to filter from @param maintree: Whether this tree is the main tree. The requester must be used to change filters against the main tree. """ self.... |
self.trace += " - - External update of %s\n" %tid | if DEBUG: self.trace += " - - External update of %s\n" %tid | def __execution_loop(self): while len(self.__updating_queue) > 0: tid,action = self.__updating_queue.pop(0) |
self.trace += " - - External delete of %s\n" %tid | if DEBUG: self.trace += " - - External delete of %s\n" %tid | def __execution_loop(self): while len(self.__updating_queue) > 0: tid,action = self.__updating_queue.pop(0) |
self.trace += " - - External add of %s\n" %tid | if DEBUG: self.trace += " - - External add of %s\n" %tid | def __execution_loop(self): while len(self.__updating_queue) > 0: tid,action = self.__updating_queue.pop(0) |
error += '\n\nDEBUG TRACE\n\n%s' %self.trace | if DEBUG: error += '\n\nDEBUG TRACE\n\n%s' %self.trace | def print_from_node(self, nid, level=0,string=None): prefix = "->"*level paths = self.get_paths_for_node(nid) toprint = "%s%s (%s) " %(prefix,nid,\ str(paths)) if not string: print toprint level += 1 is_good = False for p in paths: if len(p) == level: is_good = True if not is_good: error = 'theres no path of level %... |
return self.node_nth_child(basenode_id,path[0]) | toreturn = self.node_nth_child(basenode_id,path[0]) | def __node_for_path(self,basenode_id,path): if len(path) == 0: return basenode_id elif path[0] < self.node_n_children(basenode_id): if len(path) == 1: return self.node_nth_child(basenode_id,path[0]) else: node_id = self.node_nth_child(basenode_id,path[0]) path = path[1:] return self.__node_for_path(node_id, path) else:... |
return self.__node_for_path(node_id, path) else: return None | toreturn = self.__node_for_path(node_id, path) else: toreturn = None return toreturn | def __node_for_path(self,basenode_id,path): if len(path) == 0: return basenode_id elif path[0] < self.node_n_children(basenode_id): if len(path) == 1: return self.node_nth_child(basenode_id,path[0]) else: node_id = self.node_nth_child(basenode_id,path[0]) path = path[1:] return self.__node_for_path(node_id, path) else:... |
error += self.trace | if DEBUG: error += self.trace | def __next_nodes(self,nid,path): '''given a node and a path, return all the next nodes of that node for that path. The list is returned in reverse order (last next_node first) ''' error = "nextnodes %s %s\n" %(nid,str(path)) if len(path) >= 2: index = path[-1] parpath = path[:-1] par = self.get_node_for_path(parpath) p... |
self.trace += " remove %s from path %s\n" %(nid,str(paths)) | if DEBUG: self.trace += " remove %s from path %s\n" %(nid,str(paths)) | def __delete_node(self,nid,paths=None): '''Delete occurence of node nid for given paths. if paths is None, then the node is removed for every paths it belongs to. Deleting a node means : 1. Deleting all the next_nodes 2. Deleting all the children. 3. Deleting the node itself. 4. Re-adding all the next_nodes ''' error =... |
error += self.trace | if DEBUG: error += self.trace | def __delete_node(self,nid,paths=None): '''Delete occurence of node nid for given paths. if paths is None, then the node is removed for every paths it belongs to. Deleting a node means : 1. Deleting all the next_nodes 2. Deleting all the children. 3. Deleting the node itself. 4. Re-adding all the next_nodes ''' error =... |
self.trace += "****** We delete %s from path %s\n" %(nid,str(p)) | if DEBUG: self.trace += "****** We delete %s from path %s\n" %(nid,str(p)) | def __delete_node(self,nid,paths=None): '''Delete occurence of node nid for given paths. if paths is None, then the node is removed for every paths it belongs to. Deleting a node means : 1. Deleting all the next_nodes 2. Deleting all the children. 3. Deleting the node itself. 4. Re-adding all the next_nodes ''' error =... |
self.trace += " "+error | if DEBUG: self.trace += " "+error | def __add_node(self,nid,paths=None): error = "Adding node %s to paths %s\n" %(nid,paths) self.trace += " "+error #we only add node that really need it. curdis = self.is_displayed(nid) newdis = self.__is_displayed(nid) #it should not be displayed, don't add it. if not newdis: return False if not paths: paths = self... |
self.trace += " we wont add path %s for %s\n" %(str(pp),nid) | if DEBUG: self.trace += " we wont add path %s for %s\n" %(str(pp),nid) | def __add_node(self,nid,paths=None): error = "Adding node %s to paths %s\n" %(nid,paths) self.trace += " "+error #we only add node that really need it. curdis = self.is_displayed(nid) newdis = self.__is_displayed(nid) #it should not be displayed, don't add it. if not newdis: return False if not paths: paths = self... |
self.trace += " adding %s to path %s but occupied by %s\n"\ | error += " adding %s to path %s but occupied by %s\n"\ | def __add_node(self,nid,paths=None): error = "Adding node %s to paths %s\n" %(nid,paths) self.trace += " "+error #we only add node that really need it. curdis = self.is_displayed(nid) newdis = self.__is_displayed(nid) #it should not be displayed, don't add it. if not newdis: return False if not paths: paths = self... |
self.__delete_node(t[0],[t[1]]) | ret = self.__delete_node(t[0]) error += "%s was deleted : %s\n" %(t[0],ret) if self.cache_nodes.has_key(t[0]): error += "%s cached : %s\n" %(t[0],self.cache_nodes[t[0]]) raise Exception(error) par = self.get_node_for_path(t[1][:-1]) if t[0] in self.cache_nodes[par]['children']: error += "%s is still in %s childrens" %(... | def __add_node(self,nid,paths=None): error = "Adding node %s to paths %s\n" %(nid,paths) self.trace += " "+error #we only add node that really need it. curdis = self.is_displayed(nid) newdis = self.__is_displayed(nid) #it should not be displayed, don't add it. if not newdis: return False if not paths: paths = self... |
error += 'cached VR = %s\n' %self.cache_vr | def __add_node(self,nid,paths=None): error = "Adding node %s to paths %s\n" %(nid,paths) self.trace += " "+error #we only add node that really need it. curdis = self.is_displayed(nid) newdis = self.__is_displayed(nid) #it should not be displayed, don't add it. if not newdis: return False if not paths: paths = self... | |
error += self.trace | if DEBUG: error += self.trace | def __add_node(self,nid,paths=None): error = "Adding node %s to paths %s\n" %(nid,paths) self.trace += " "+error #we only add node that really need it. curdis = self.is_displayed(nid) newdis = self.__is_displayed(nid) #it should not be displayed, don't add it. if not newdis: return False if not paths: paths = self... |
self.trace += " +++++ %s added to %s\n" %(nid,str(p)) | if DEBUG: self.trace += " +++++ %s added to %s\n" %(nid,str(p)) | def __add_node(self,nid,paths=None): error = "Adding node %s to paths %s\n" %(nid,paths) self.trace += " "+error #we only add node that really need it. curdis = self.is_displayed(nid) newdis = self.__is_displayed(nid) #it should not be displayed, don't add it. if not newdis: return False if not paths: paths = self... |
self.trace += " ______ %s modified in %s\n" %(nid,str(p)) | if DEBUG: self.trace += " ______ %s modified in %s\n" %(nid,str(p)) | def __update_node(self,nid): '''to update a node, we: 1. take old and new paths 2. we remove all occurence that are in oldpaths and not in newpaths 3. we refresh newpaths to reflect the deletions. 4. We add the occurence in newpaths and not in oldpaths 5. we update nodes that are in both paths ''' error = " Updating no... |
error += self.trace | if DEBUG: error += self.trace | def __update_node(self,nid): '''to update a node, we: 1. take old and new paths 2. we remove all occurence that are in oldpaths and not in newpaths 3. we refresh newpaths to reflect the deletions. 4. We add the occurence in newpaths and not in oldpaths 5. we update nodes that are in both paths ''' error = " Updating no... |
searchList = [{ 'tasks': tasks_str}])) | searchList = [parameters_dict])) | def export_generate(self): #Template loading and cutting if self.export_all_active.get_active(): #Export the active tasks in the current view (the ones visible in # the Task Browser model = self.plugin_api.get_task_modelsort() tasks_str = self.treemodel_to_TaskStr(model, model.get_iter_first()) elif self.export_finishe... |
self.view_main_window.connect('activate', self.minimize, self.plugin_api) | self.view_main_window_signal = self.view_main_window.connect(\ 'activate', \ self.minimize, \ self.plugin_api) | def create_static_menu(self): self.menu = gtk.Menu() self.view_main_window = gtk.CheckMenuItem(_("_View Main Window")) self.view_main_window.set_active(True) self.view_main_window.connect('activate', self.minimize, self.plugin_api) self.menu.append(self.view_main_window) # menuItem = gtk.ImageMenuItem(gtk.STOCK_ABOUT) ... |
@dbus.service.method(BUSNAME,in_signature="s") def get_task_ids(self, status_string): status = [s.strip() for s in status_string.split(',')] status = [unicodedata.normalize('NFKD', s).encode('ascii','ignore') \ for s in status] return self.req.get_tasks_list(status = status) | def __init__(self, req, view_manager): # Attach the object to D-Bus self.bus = dbus.SessionBus() bus_name = dbus.service.BusName(BUSNAME, bus=self.bus) dbus.service.Object.__init__(self, bus_name, BUSFACE) self.req = req self.view_manager = view_manager | |
return [self.get_task(id) for id in self.get_task_ids()] | return self.get_tasks_filtered(['all']) | def get_tasks(self): # Retrieve a list of task data dicts return [self.get_task(id) for id in self.get_task_ids()] |
for tag in task.get_tags(): self.tagrefresh(sender=sender,tagname=tag.get_name()) | if task: for tag in task.get_tags(): self.tagrefresh(sender=sender,tagname=tag.get_name()) | def refresh(self,sender=None,tid=None): if tid: task = self.req.get_task(tid) for tag in task.get_tags(): self.tagrefresh(sender=sender,tagname=tag.get_name()) |
print "*** end of refiltering ****" for n in self.virtual_root: self.__update_node(n,True) | def refilter(self): """ rebuilds the tree from scratch. It should be called only when the filter is changed (i.e. only filters_bank should call it). """ self.update_count = 0 self.add_count = 0 self.remove_count = 0 virtual_root2 = [] to_add = [] #self.displayed_nodes = [] self.counted_nodes = [] #If we have only one f... | |
self.ind = appindicator.Indicator ("gtg", "indicator-messages", appindicator.CATEGORY_APPLICATION_STATUS) | self.ind = appindicator.Indicator ("gtg", \ "indicator-messages", \ appindicator.CATEGORY_APPLICATION_STATUS) | def activate(self, plugin_api): self.plugin_api = plugin_api #Create the menu self.create_static_menu() #initialize the right notification thing if indicator_capable: #Create an indicator icon self.ind = appindicator.Indicator ("gtg", "indicator-messages", appindicator.CATEGORY_APPLICATION_STATUS) self.ind.set_status ... |
icon = gtk.gdk.pixbuf_new_from_file_at_size(data_dir + "/icons/hicolor/16x16/apps/gtg.png", 16, 16) | icon = gtk.gdk.pixbuf_new_from_file_at_size(data_dir + \ "/icons/hicolor/16x16/apps/gtg.png", 16, 16) | def activate(self, plugin_api): self.plugin_api = plugin_api #Create the menu self.create_static_menu() #initialize the right notification thing if indicator_capable: #Create an indicator icon self.ind = appindicator.Indicator ("gtg", "indicator-messages", appindicator.CATEGORY_APPLICATION_STATUS) self.ind.set_status ... |
self.status_icon.connect('popup-menu', self.on_icon_popup, self.menu) | self.status_icon.connect('popup-menu', \ self.on_icon_popup, \ self.menu) | def activate(self, plugin_api): self.plugin_api = plugin_api #Create the menu self.create_static_menu() #initialize the right notification thing if indicator_capable: #Create an indicator icon self.ind = appindicator.Indicator ("gtg", "indicator-messages", appindicator.CATEGORY_APPLICATION_STATUS) self.ind.set_status ... |
self.minimized = not self.minimized | self.minimized = False | def minimize(self, widget, plugin_api): if self.minimized: self.view_main_window.set_active(True) plugin_api.show_window() self.minimized = not self.minimized else: self.view_main_window.set_active(False) plugin_api.hide_window() self.minimized = not self.minimized |
self.minimized = not self.minimized | self.minimized = True self.view_main_window_signal = self.view_main_window.connect(\ 'activate', self.minimize, self.plugin_api) | def minimize(self, widget, plugin_api): if self.minimized: self.view_main_window.set_active(True) plugin_api.show_window() self.minimized = not self.minimized else: self.view_main_window.set_active(False) plugin_api.hide_window() self.minimized = not self.minimized |
self.view_main_window.connect('activate', self.minimize, self.plugin_api) | self.view_main_window_signal = self.view_main_window.connect(\ 'activate', \ self.minimize,\ self.plugin_api) | def create_static_menu(self): #Tasks_in_menu will hold the menu_items in the menu self.tasks_in_menu = dict() self.task_separator = None self.menu = gtk.Menu() #view in main window checkbox self.view_main_window = gtk.CheckMenuItem(_("_View Main Window")) self.view_main_window.set_active(not self.minimized) self.view_m... |
menu.popup(None, None, gtk.status_icon_position_menu, button, timestamp, icon) | menu.popup(None, None, gtk.status_icon_position_menu, \ button, timestamp, icon) | def on_icon_popup(self, icon, button, timestamp, menu=None): #appindicator handles menus transparently if not indicator_capable: menu.popup(None, None, gtk.status_icon_position_menu, button, timestamp, icon) |
'on_quit_button_clicked': self.on_close, | 'on_close_button_clicked': self.on_close, | def _setup_signal_connections(self, builder): ''' Creates some GTK signals connections |
if node and (node.get_id() in self.tasks_to_add): self.tasks_to_add.remove(node.get_id()) return rowref | if node.get_id() in self.tasks_to_add: self.tasks_to_add.remove(node.get_id()) return rowref else: return None | def on_get_iter(self, path): #We have to return None if there's no node on that path iter = None |
print "colony_screen::run() ... colony.build_queue[] = %s" % colony.build_queue()[0] print "colony_screen::run() ... colony.build_queue[] = %s" % colony.build_queue()[1] print "colony_screen::run() ... colony.build_queue[] = %s" % colony.build_queue()[2] print "colony_screen::run() ... colony.build_queue[] = %s" % colo... | for build_item in colony.get_build_queue(): print "colony_screen::run() ... colony.build_queue[] = %s" % build_item | def run(self, GAME, colony_id): |
info_x, info_y = self.__panel_x + 15, self.__panel_y + 49 | info_x, info_y = self.get_normalized_panel_pos((self.__panel_x, self.__panel_y)) info_x += 15 info_y += 49 | def draw_planet_info(self, text_rows): DISPLAY = self.get_display() font3 = self.get_font3() info_palette = [0x0, 0x181c40, 0x688cb0] info_x, info_y = self.__panel_x + 15, self.__panel_y + 49 rows = [] width, height = 0, 6 for text_line in text_rows: rows.append(font3.render(text_line, info_palette, 1)) height += 13 wi... |
self.__panel_x, self.__panel_y = self.get_norlalized_panel_pos((self.__panel_x, self.__panel_y)) | self.__panel_x, self.__panel_y = self.get_normalized_panel_pos((self.__panel_x, self.__panel_y)) | def run(self, GAME, star_id): self.__GAME = GAME |
def signal_to_spikes_1D(fs, signal): | def _signal_to_spikes(fs, signal): | def signal_to_spikes_1D(fs, signal): """ Convert 1D time function array into array of spike timings. fs: sampling frequency in Hz signal: input signal return: spike timings in ms >>> fs = 10 >>> signal = np.array([0,2,0,0,1,0]) >>> signal_to_spikes_1D(fs, signal) array([ 100., 100., 400.]) """ assert signal.ndim ... |
>>> signal_to_spikes_1D(fs, signal) | >>> _signal_to_spikes(fs, signal) | def signal_to_spikes_1D(fs, signal): """ Convert 1D time function array into array of spike timings. fs: sampling frequency in Hz signal: input signal return: spike timings in ms >>> fs = 10 >>> signal = np.array([0,2,0,0,1,0]) >>> signal_to_spikes_1D(fs, signal) array([ 100., 100., 400.]) """ assert signal.ndim ... |
spike_trains = [ signal_to_spikes_1D(fs, signals) ] | spike_trains = [ _signal_to_spikes(fs, signals) ] | def signal_to_spikes(fs, signals): """ Convert time functions to a list of spike trains. fs: samping frequency in Hz signals: input signals return: spike trains with spike timings >>> fs = 10 >>> s = np.array([[0,0,0,1,0,0], [0,2,1,0,0,0]]).T >>> signal_to_spikes(fs, s) [array([ 300.]), array([ 100., 100., 200.])]... |
spike_trains = [ signal_to_spikes_1D(fs, signal) | spike_trains = [ _signal_to_spikes(fs, signal) | def signal_to_spikes(fs, signals): """ Convert time functions to a list of spike trains. fs: samping frequency in Hz signals: input signals return: spike trains with spike timings >>> fs = 10 >>> s = np.array([[0,0,0,1,0,0], [0,2,1,0,0,0]]).T >>> signal_to_spikes(fs, s) [array([ 300.]), array([ 100., 100., 200.])]... |
assert False | assert False, "Input signal must be 1 or 2 dimensional" | def signal_to_spikes(fs, signals): """ Convert time functions to a list of spike trains. fs: samping frequency in Hz signals: input signals return: spike trains with spike timings >>> fs = 10 >>> s = np.array([[0,0,0,1,0,0], [0,2,1,0,0,0]]).T >>> signal_to_spikes(fs, s) [array([ 300.]), array([ 100., 100., 200.])]... |
def spikes_to_signal_1D(fs, spikes, tmax=None): | def _spikes_to_signal(fs, spikes, tmax=None): | def signal_to_spikes(fs, signals): """ Convert time functions to a list of spike trains. fs: samping frequency in Hz signals: input signals return: spike trains with spike timings >>> fs = 10 >>> s = np.array([[0,0,0,1,0,0], [0,2,1,0,0,0]]).T >>> signal_to_spikes(fs, s) [array([ 300.]), array([ 100., 100., 200.])]... |
>>> spikes_to_signal_1D(fs, spikes) | >>> _spikes_to_signal(fs, spikes) | def spikes_to_signal_1D(fs, spikes, tmax=None): """ Convert spike train to its time function. 1D version. >>> fs = 10 >>> spikes = np.array([100, 500, 1000, 1000]) >>> spikes_to_signal_1D(fs, spikes) array([0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 2]) """ if tmax == None: tmax = max(spikes) bins = np.ceil(tmax*fs/1000) + 1 sig... |
array([[ 0., 0.], [ 1., 0.], [ 0., 1.], [ 0., 1.]]) | array([[0, 0], [1, 0], [0, 1], [0, 1]]) | def spikes_to_signal(fs, spike_trains, tmax=None): """ Convert spike trains to theirs time functions. fs: sampling frequency (Hz) spike_trains: trains of spikes to be converted (ms) tmax: length of the output signal (ms) return: time signal >>> spikes_to_signal(10, [np.array([100]), np.array([200, 300])]) array([[ 0... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.