Back to index

python3.2  3.2.2
Functions | Variables
makelocalealias Namespace Reference

Functions

def parse
def pprint
def print_differences

Variables

string LOCALE_ALIAS = '/usr/share/X11/locale/locale.alias'
tuple data = locale.locale_alias.copy()

Function Documentation

def makelocalealias.parse (   filename)

Definition at line 14 of file makelocalealias.py.

00014 
00015 def parse(filename):
00016 
00017     f = open(filename)
00018     lines = f.read().splitlines()
00019     data = {}
00020     for line in lines:
00021         line = line.strip()
00022         if not line:
00023             continue
00024         if line[:1] == '#':
00025             continue
00026         locale, alias = line.split()
00027         # Strip ':'
00028         if locale[-1] == ':':
00029             locale = locale[:-1]
00030         # Lower-case locale
00031         locale = locale.lower()
00032         # Ignore one letter locale mappings (except for 'c')
00033         if len(locale) == 1 and locale != 'c':
00034             continue
00035         # Normalize encoding, if given
00036         if '.' in locale:
00037             lang, encoding = locale.split('.')[:2]
00038             encoding = encoding.replace('-', '')
00039             encoding = encoding.replace('_', '')
00040             locale = lang + '.' + encoding
00041             if encoding.lower() == 'utf8':
00042                 # Ignore UTF-8 mappings - this encoding should be
00043                 # available for all locales
00044                 continue
00045         data[locale] = alias
00046     return data

def makelocalealias.pprint (   data)

Definition at line 47 of file makelocalealias.py.

00047 
00048 def pprint(data):
00049     items = sorted(data.items())
00050     for k, v in items:
00051         print('    %-40s%r,' % ('%r:' % k, v))

Here is the call graph for this function:

def makelocalealias.print_differences (   data,
  olddata 
)

Definition at line 52 of file makelocalealias.py.

00052 
00053 def print_differences(data, olddata):
00054     items = sorted(olddata.items())
00055     for k, v in items:
00056         if k not in data:
00057             print('#    removed %r' % k)
00058         elif olddata[k] != data[k]:
00059             print('#    updated %r -> %r to %r' % \
00060                   (k, olddata[k], data[k]))
00061         # Additions are not mentioned

Here is the call graph for this function:


Variable Documentation

tuple makelocalealias.data = locale.locale_alias.copy()

Definition at line 63 of file makelocalealias.py.

Definition at line 12 of file makelocalealias.py.