~mvo/software-center/trivial-renaming

« back to all changes in this revision

Viewing changes to softwarecenter/utils.py

merged review code

Show diffs side-by-side

added added

removed removed

Lines of Context:
38
38
ESCAPE_ENTITIES = {"'":"'",
39
39
                   '"':'"'}
40
40
 
 
41
 
41
42
class ExecutionTime(object):
42
43
    """
43
44
    Helper that can be used in with statements to have a simple
112
113
    if inside_p:
113
114
        yield "</p>"
114
115
 
 
116
def get_parent_xid(widget):
 
117
    while widget.get_parent():
 
118
        widget = widget.get_parent()
 
119
    return widget.window.xid
 
120
 
 
121
def get_language():
 
122
    """Helper that returns the current language
 
123
    """
 
124
    import locale
 
125
    # those languages need the full language-code, the other ones
 
126
    # can be abbreved
 
127
    FULL = ["pt_BR", 
 
128
            "zh_CN", "zh_TW"]
 
129
    (language, encoding) = locale.getlocale()
 
130
    if language in FULL:
 
131
        return language
 
132
    return language.split("_")[0]
 
133
 
115
134
def get_http_proxy_string_from_gconf():
116
135
    """Helper that gets the http proxy from gconf
117
136
 
306
325
    def stop(self):
307
326
        pass
308
327
 
 
328
def hash_pkgname_for_changelogs(pkgname):
 
329
    """ hash pkgname for changelogs.ubuntu.com 
 
330
        returns  "a" for "abcd"
 
331
                 "liba" for "libabcd"
 
332
    """
 
333
    if pkgname.startswith("lib"):
 
334
        return pkgname[0:4]
 
335
    return pkgname[0:1]
 
336
 
309
337
if __name__ == "__main__":
310
338
    s = decode_xml_char_reference('Search&#x2026;')
311
339
    print s