Back to index

plone3  3.1.7
Functions | Variables
utils Namespace Reference

Functions

def getPoFiles
def getPotFiles
def getPoFilesAsCmdLine
def getPotFilesAsCmdLine
def getPoFilesByLanguageCode
def getLanguage
def getProduct
def getLongProductName
def getProductPath

Variables

dictionary PRODUCTS
list PRODUCTNAMES = [PRODUCTS[abbr]['name'] for abbr in PRODUCTS]

Function Documentation

def utils.getLanguage (   product,
  f 
)
Returns the language part of a po-file 

Definition at line 72 of file utils.py.

00072 
00073 def getLanguage(product, f):
00074     """ Returns the language part of a po-file """
00075     lang = None
00076     if f.endswith('.po'):
00077         if f.startswith(product):
00078             lang = '-'.join(f.split('-')[1:])[:-3]
00079     return lang
00080 

Here is the caller graph for this function:

def utils.getLongProductName (   product)
Returns the product name for a known abbreviation.

Definition at line 93 of file utils.py.

00093 
00094 def getLongProductName(product):
00095     """ Returns the product name for a known abbreviation."""
00096     if product in PRODUCTS.keys():
00097         return PRODUCTS[product]['name']
00098     return product
00099 

Here is the caller graph for this function:

def utils.getPoFiles (   product,
  all = False 
)
Returns all product*.po files in the current folder 

Definition at line 19 of file utils.py.

00019 
00020 def getPoFiles(product, all=False):
00021     """ Returns all product*.po files in the current folder """
00022     path = os.curdir
00023     folder = ''
00024     if '/' in product:
00025         folder, product = product.split('/')
00026         path = os.path.join(os.curdir, folder)
00027 
00028     files = os.listdir(path)
00029     if all:
00030         files = [f for f in files if f.startswith('%s-' % product) and f.endswith('.po')]
00031     else:
00032         files = [f for f in files if f.startswith('%s-' % product) and f.endswith('.po') and f != '%s-en.po' % product]
00033     if folder:
00034         files  = [folder + '/' + f for f in files]
00035     return files
00036 

Here is the caller graph for this function:

def utils.getPoFilesAsCmdLine (   product)

Definition at line 49 of file utils.py.

00049 
00050 def getPoFilesAsCmdLine(product):
00051     files = getPoFiles(product)
00052     filestring = ''
00053     for f in files:
00054         filestring += f + ' '
00055     return filestring.rstrip()
00056 

Here is the call graph for this function:

Here is the caller graph for this function:

Returns all po files which ends with given language code.

Definition at line 65 of file utils.py.

00065 
00066 def getPoFilesByLanguageCode(lang):
00067     """ Returns all po files which ends with given language code."""
00068     files = os.listdir(os.curdir)
00069     files = [f for f in files if f.endswith('.po') and f[:-3].endswith(lang)]
00070     return files
00071 

Here is the caller graph for this function:

def utils.getPotFiles (   all = False)
Returns all pot files in the current folder
    Normally it doesn't return manual.pots and generated.pots

Definition at line 37 of file utils.py.

00037 
00038 def getPotFiles(all=False):
00039     """ Returns all pot files in the current folder
00040         Normally it doesn't return manual.pots and generated.pots
00041     """
00042     files = os.listdir(os.curdir)
00043     if all:
00044         files = [f for f in files if f.endswith('.pot')]
00045     else:
00046         files = [f for f in files if f.endswith('.pot') and not f[:-4].endswith('manual') and not f[:-4].endswith('generated')]
00047     return files
00048 

Here is the caller graph for this function:

Definition at line 57 of file utils.py.

00057 
00058 def getPotFilesAsCmdLine():
00059     files = getPotFiles()
00060     filestring = ''
00061     for f in files:
00062         filestring += f + ' '
00063     return filestring.rstrip()
00064 

Here is the call graph for this function:

def utils.getProduct (   f)
Returns the product part of a file. We assume files to be something like domain-language.po.
    Example: atcontenttypes-pt-br.po

Definition at line 81 of file utils.py.

00081 
00082 def getProduct(f):
00083     """ Returns the product part of a file. We assume files to be something like domain-language.po.
00084         Example: atcontenttypes-pt-br.po
00085     """
00086     assert f.endswith('.po') or f.endswith('.pot')
00087 
00088     f = f.split('.')[0] # strip of ending
00089     f = f.split('-')[0] # only take product
00090 
00091     return f
00092 

Here is the caller graph for this function:

def utils.getProductPath (   product)
Returns the product path for a known abbreviation.

Definition at line 100 of file utils.py.

00100 
00101 def getProductPath(product):
00102     """ Returns the product path for a known abbreviation."""
00103     if product in PRODUCTS.keys():
00104         return PRODUCTS[product]['path']
00105     if product in PRODUCTNAMES:
00106         for abbr in PRODUCTS.keys():
00107             if PRODUCTS[abbr]['name'] == product:
00108                 return PRODUCTS[abbr]['path']
00109     return product

Here is the caller graph for this function:


Variable Documentation

list utils.PRODUCTNAMES = [PRODUCTS[abbr]['name'] for abbr in PRODUCTS]

Definition at line 17 of file utils.py.

dictionary utils.PRODUCTS
Initial value:
00001 {
00002     'atct'  : {'name': 'atcontenttypes', 'path': 'ATContentTypes'},
00003     'atrbw' : {'name': 'atreferencebrowserwidget', 'path': 'ATReferenceBrowserWidget'},
00004     'lp'    : {'name': 'linguaplone', 'path': 'LinguaPlone'},
00005     'plone' : {'name': 'plone', 'path': 'CMFPlone'},
00006     'plt'   : {'name': 'plonelanguagetool', 'path': 'PloneLanguageTool'},
00007     'prt'   : {'name': 'passwordresettool', 'path': 'PasswordResetTool'},
00008     'cmfpw' : {'name': 'cmfplacefulworkflow', 'path': 'CMFPlacefulWorkflow'},
00009     'cmfe'  : {'name': 'cmfeditions', 'path': 'CMFEditions'},
00010     'kupu'  : {'name': 'kupu/kupu', 'path': 'kupu'},
00011     'kupuconfig'  : {'name': 'kupu/kupuconfig', 'path': 'kupu'},
00012     'kupupox'  : {'name': 'kupu/kupupox', 'path': 'kupu'},
00013     }

Definition at line 3 of file utils.py.