Ejemplo n.º 1
0
def alfred_xml(query):
    symbols_list = filter_symbols(query)
    al = AlfredItemsList()
    for hex_string, symbol, description, idx in symbols_list:
        al.append(arg=idx,
                  title=' ' + symbol,
                  subtitle=description,
                  uid='utf_symbols' + str(idx))
    return al
Ejemplo n.º 2
0
def alfred_xml(query):
    symbols_list = filter_symbols(query)
    al = AlfredItemsList()
    for hex_string, symbol, description, idx in symbols_list:
        al.append(
            arg=idx,
            title=' ' + symbol,
            subtitle=description,
            uid='utf_symbols' + str(idx)
        )
    return al
Ejemplo n.º 3
0
 def as_alfred_xml(self, include_projects=False, additional_arg=None):
     al = AlfredItemsList()
     if self.type != "project" or include_projects:
         al.append(
             arg=str(self.title._id) + ((";" + additional_arg) if additional_arg else ""),
             # _id never has `;` in it so it's safe encoding
             title=self.title.text,
             subtitle=self.parents_to_str(),
             icon="done" if self.is_done() else self.type,
         )
     if self.sub_tasks:
         al += self.sub_tasks.as_alfred_xml(include_projects, additional_arg)
     return al
Ejemplo n.º 4
0
 def as_alfred_xml(self, include_projects=False, additional_arg=None):
     al = AlfredItemsList()
     if self.type != 'project' or include_projects:
         al.append(
             arg=str(self.title._id) + \
                 ((';' + additional_arg) if additional_arg else ''),
             # _id never has `;` in it so it's safe encoding
             title=self.title.text,
             subtitle=self.parents_to_str(),
             icon='done' if self.is_done() else self.type
         )
     if self.sub_tasks:
         al += self.sub_tasks.as_alfred_xml(include_projects,
                                            additional_arg)
     return al
Ejemplo n.º 5
0
 def as_alfred_xml(self, include_projects=False, additional_arg=None):
     al = AlfredItemsList()
     for item in self.items:
         al_item = item.as_alfred_xml(include_projects, additional_arg)
         if al_item:  # item returns None if it shouldn't be displayed in alfred
             al += al_item
     return al
Ejemplo n.º 6
0
def to_alfred_xml(query):
    items = None
    with open(full_path, 'r') as f:
        text = f.read()
        if text:
            items = set(text.split('\t'))

    if not items:
        return  # alfred will display "Please wait" subtext

    al = AlfredItemsList()
    # add selected files
    for item in items:
        if query.lower() in item.lower():
            al.append(
                arg=item,
                title='/'.join(item.split('/')[-2:]),
                subtitle='',
                icon='remove'.format(item))
    return al
def convert(text):
    al = AlfredItemsList()
    for conversion in convert_currency(text):
        al.append(unicode(conversion.converted_amount), unicode(conversion), "")
    print al
Ejemplo n.º 8
0
def to_alfred_xml(arg, show_tags=True):
    items = set()
    with open(full_path, 'r') as f:
        text = f.read()
        if text:
            items = set(text.split('\t'))
    if not items:
        return  # alfred will display "Please wait" subtext

    al = AlfredItemsList()
    # add constant items
    al.append(
        arg=(arg, '--add'),
        title='Add tags',
        subtitle=arg,
        icon='<icon>icon_add.png</icon>'
    )
    al.append(
        arg=(arg, '--rem'),
        title='Remove tags',
        subtitle=arg,
        icon='<icon>icon_rem.png</icon>'
    )
    if show_tags:
        tags = {}
        all_tags = set()
        for item in items:
            t = get_tags(item)
            tags[item] = " ".join(t) if t else "-no tags-"
            all_tags.update(t)

    al.append(
        arg=(arg, '--clear tags'),
        title='Clear all tags',
        subtitle=" ".join(all_tags) if show_tags else "",
        icon='<icon>icon_rem.png</icon>'
    )
    al.append(
        arg=(arg, '--clear selection'),
        title='Clear selection',
        subtitle='',
        icon='<icon>icon_blu.png</icon>'
    )

    # add selected files
    for item in items:
        al.append(
            arg=(arg, item),
            title='/'.join(item.split('/')[-2:]),
            subtitle=tags[item] if show_tags else "",
            icon='<icon type="fileicon">{0}</icon>'.format(item))
    return al