Added docs-tfg and implemented functionality of warning in case object is bigger than printer area

This commit is contained in:
Javierma87 committed 2016-02-11 18:32:36 +00:00
1 parent dedadbc9ac
commit caf4e84ab2
1889 files changed
+491678 -2

No files matched your search

@@ -0,0 +1,15 @@
Requirements for warning if object exceedes printing area
-Check if file is gcode (stl as well?)
-Consult G0 and G1 commands
-Consult dimensions in settings (possible to do also in firmware?)
-Compare command values with dimensions
Solution:
-Changed analysis.py under /src/octoprint
-Added warning to result, which can be true or false depending on the analysis.
-Changed files.js under /src/octoprint/static/js/app/viewmodels
-Checked data["gcodeAnalysis"]["warning"]. In case it is true, creates a new Pnotify object to warn the user that an object inside the file exceeds the printing area.
-Checked data["name"] to get the name of the file
+9
View File
@@ -0,0 +1,9 @@
Requirements to integrate Slic3r:
-Integration of Slic3r as a plugin
-Add Slic3r to plugins menu under settings
-When Slic3r is selected, add:
-A box to introduce the path
-A box to introduce each of the related profile files:
-Print settings
-Filament settings
-Printer settings
+4 -1
View File
@@ -17,6 +17,8 @@ from octoprint.events import Events, eventManager
import octoprint.util.gcodeInterpreter as gcodeInterpreter
#Added to check if object exceeds printing area
from octoprint.printer.profile import PrinterProfileManager
class QueueEntry(collections.namedtuple("QueueEntry", "path, type, location, absolute_path, printer_profile")):
"""
@@ -258,8 +260,9 @@ class GcodeAnalysisQueue(AbstractAnalysisQueue):
self._gcode = gcodeInterpreter.gcode()
self._gcode.load(self._current.absolute_path, self._current.printer_profile, throttle=throttle_callback)
result = dict()
result["warning"]=self._gcode.getWarning()
if self._gcode.totalMoveTimeMinute:
result["estimatedPrintTime"] = self._gcode.totalMoveTimeMinute * 60
if self._gcode.extrusionAmount:
@@ -327,6 +327,17 @@ $(function() {
}
}
output += gettext("Estimated Print Time") + ": " + formatDuration(data["gcodeAnalysis"]["estimatedPrintTime"]) + "<br>";
if(data["gcodeAnalysis"]["warning"])
{
var warning = "<p>" + gettext("Object exceeds printing area") + "</p>";
warning += pnotifyAdditionalInfo("<pre>Object or objects in file '"+data["name"]+"' exceeds the printing area</pre>");
new PNotify({
title: "Object dimensions",
text: warning,
type: "warning",
hide: false
});
}
}
if (data["prints"] && data["prints"]["last"]) {
output += gettext("Last Printed") + ": " + formatTimeAgo(data["prints"]["last"]["date"]) + "<br>";
@@ -402,11 +413,17 @@ $(function() {
if (_.endsWith(filename.toLowerCase(), ".stl")) {
self.slicing.show(location, filename);
}
if (data.result.done) {
$("#gcode_upload_progress .bar").css("width", "0%");
$("#gcode_upload_progress").removeClass("progress-striped").removeClass("active");
$("#gcode_upload_progress .bar").text("");
/*var cadena="";
for(var i in data)
{
cadena+=" "+i+"\t";
};*/
}
}
+11
View File
@@ -30,6 +30,8 @@ class gcode(object):
self.progressCallback = None
self._abort = False
self._filamentDiameter = 0
#Parameters for object size checking
self.warn=False
def load(self, filename, printer_profile, throttle=None):
if os.path.isfile(filename):
@@ -117,6 +119,13 @@ class gcode(object):
z = getCodeFloat(line, 'Z')
e = getCodeFloat(line, 'E')
f = getCodeFloat(line, 'F')
#Check if x,y or z exceeds printing area
width=float(printer_profile["volume"]["width"])
depth=float(printer_profile["volume"]["depth"])
height=float(printer_profile["volume"]["height"])
if not self.warn and (x>width or y>depth or z>height):
self.warn=True
self._logger.warn("Object is bigger than the printing area")
oldPos = pos
pos = pos[:]
if posAbs:
@@ -255,6 +264,8 @@ class gcode(object):
def _parseCuraProfileString(self, comment, prefix):
return {key: value for (key, value) in map(lambda x: x.split("=", 1), zlib.decompress(base64.b64decode(comment[len(prefix):])).split("\b"))}
def getWarning(self):
return self.warn
def getCodeInt(line, code):
n = line.find(code) + 1
+80
View File
@@ -0,0 +1,80 @@
# This file must be used with "source bin/activate" *from bash*
# you cannot run it directly
deactivate () {
unset pydoc
# reset old environment variables
if [ -n "$_OLD_VIRTUAL_PATH" ] ; then
PATH="$_OLD_VIRTUAL_PATH"
export PATH
unset _OLD_VIRTUAL_PATH
fi
if [ -n "$_OLD_VIRTUAL_PYTHONHOME" ] ; then
PYTHONHOME="$_OLD_VIRTUAL_PYTHONHOME"
export PYTHONHOME
unset _OLD_VIRTUAL_PYTHONHOME
fi
# This should detect bash and zsh, which have a hash command that must
# be called to get it to forget past commands. Without forgetting
# past commands the $PATH changes we made may not be respected
if [ -n "$BASH" -o -n "$ZSH_VERSION" ] ; then
hash -r 2>/dev/null
fi
if [ -n "$_OLD_VIRTUAL_PS1" ] ; then
PS1="$_OLD_VIRTUAL_PS1"
export PS1
unset _OLD_VIRTUAL_PS1
fi
unset VIRTUAL_ENV
if [ ! "$1" = "nondestructive" ] ; then
# Self destruct!
unset -f deactivate
fi
}
# unset irrelevant variables
deactivate nondestructive
VIRTUAL_ENV="/home/pi/OctoPrint-TFG/venv"
export VIRTUAL_ENV
_OLD_VIRTUAL_PATH="$PATH"
PATH="$VIRTUAL_ENV/bin:$PATH"
export PATH
# unset PYTHONHOME if set
# this will fail if PYTHONHOME is set to the empty string (which is bad anyway)
# could use `if (set -u; : $PYTHONHOME) ;` in bash
if [ -n "$PYTHONHOME" ] ; then
_OLD_VIRTUAL_PYTHONHOME="$PYTHONHOME"
unset PYTHONHOME
fi
if [ -z "$VIRTUAL_ENV_DISABLE_PROMPT" ] ; then
_OLD_VIRTUAL_PS1="$PS1"
if [ "x" != x ] ; then
PS1="$PS1"
else
if [ "`basename \"$VIRTUAL_ENV\"`" = "__" ] ; then
# special case for Aspen magic directories
# see http://www.zetadev.com/software/aspen/
PS1="[`basename \`dirname \"$VIRTUAL_ENV\"\``] $PS1"
else
PS1="(`basename \"$VIRTUAL_ENV\"`)$PS1"
fi
fi
export PS1
fi
alias pydoc="python -m pydoc"
# This should detect bash and zsh, which have a hash command that must
# be called to get it to forget past commands. Without forgetting
# past commands the $PATH changes we made may not be respected
if [ -n "$BASH" -o -n "$ZSH_VERSION" ] ; then
hash -r 2>/dev/null
fi
+42
View File
@@ -0,0 +1,42 @@
# This file must be used with "source bin/activate.csh" *from csh*.
# You cannot run it directly.
# Created by Davide Di Blasi <davidedb@gmail.com>.
alias deactivate 'test $?_OLD_VIRTUAL_PATH != 0 && setenv PATH "$_OLD_VIRTUAL_PATH" && unset _OLD_VIRTUAL_PATH; rehash; test $?_OLD_VIRTUAL_PROMPT != 0 && set prompt="$_OLD_VIRTUAL_PROMPT" && unset _OLD_VIRTUAL_PROMPT; unsetenv VIRTUAL_ENV; test "\!:*" != "nondestructive" && unalias deactivate && unalias pydoc'
# Unset irrelevant variables.
deactivate nondestructive
setenv VIRTUAL_ENV "/home/pi/OctoPrint-TFG/venv"
set _OLD_VIRTUAL_PATH="$PATH"
setenv PATH "$VIRTUAL_ENV/bin:$PATH"
if ("" != "") then
set env_name = ""
else
if (`basename "$VIRTUAL_ENV"` == "__") then
# special case for Aspen magic directories
# see http://www.zetadev.com/software/aspen/
set env_name = `basename \`dirname "$VIRTUAL_ENV"\``
else
set env_name = `basename "$VIRTUAL_ENV"`
endif
endif
# Could be in a non-interactive environment,
# in which case, $prompt is undefined and we wouldn't
# care about the prompt anyway.
if ( $?prompt ) then
set _OLD_VIRTUAL_PROMPT="$prompt"
set prompt = "[$env_name] $prompt"
endif
unset env_name
alias pydoc python -m pydoc
rehash
+74
View File
@@ -0,0 +1,74 @@
# This file must be used with "source bin/activate.fish" *from fish* (http://fishshell.com)
# you cannot run it directly
function deactivate -d "Exit virtualenv and return to normal shell environment"
# reset old environment variables
if test -n "$_OLD_VIRTUAL_PATH"
set -gx PATH $_OLD_VIRTUAL_PATH
set -e _OLD_VIRTUAL_PATH
end
if test -n "$_OLD_VIRTUAL_PYTHONHOME"
set -gx PYTHONHOME $_OLD_VIRTUAL_PYTHONHOME
set -e _OLD_VIRTUAL_PYTHONHOME
end
if test -n "$_OLD_FISH_PROMPT_OVERRIDE"
# set an empty local fish_function_path, so fish_prompt doesn't automatically reload
set -l fish_function_path
# erase the virtualenv's fish_prompt function, and restore the original
functions -e fish_prompt
functions -c _old_fish_prompt fish_prompt
functions -e _old_fish_prompt
set -e _OLD_FISH_PROMPT_OVERRIDE
end
set -e VIRTUAL_ENV
if test "$argv[1]" != "nondestructive"
# Self destruct!
functions -e deactivate
end
end
# unset irrelevant variables
deactivate nondestructive
set -gx VIRTUAL_ENV "/home/pi/OctoPrint-TFG/venv"
set -gx _OLD_VIRTUAL_PATH $PATH
set -gx PATH "$VIRTUAL_ENV/bin" $PATH
# unset PYTHONHOME if set
if set -q PYTHONHOME
set -gx _OLD_VIRTUAL_PYTHONHOME $PYTHONHOME
set -e PYTHONHOME
end
if test -z "$VIRTUAL_ENV_DISABLE_PROMPT"
# fish uses a function instead of an env var to generate the prompt.
# copy the current fish_prompt function as the function _old_fish_prompt
functions -c fish_prompt _old_fish_prompt
# with the original prompt function copied, we can override with our own.
function fish_prompt
# Prompt override?
if test -n ""
printf "%s%s" "" (set_color normal)
_old_fish_prompt
return
end
# ...Otherwise, prepend env
set -l _checkbase (basename "$VIRTUAL_ENV")
if test $_checkbase = "__"
# special case for Aspen magic directories
# see http://www.zetadev.com/software/aspen/
printf "%s[%s]%s " (set_color -b blue white) (basename (dirname "$VIRTUAL_ENV")) (set_color normal)
_old_fish_prompt
else
printf "%s(%s)%s" (set_color -b blue white) (basename "$VIRTUAL_ENV") (set_color normal)
_old_fish_prompt
end
end
set -gx _OLD_FISH_PROMPT_OVERRIDE "$VIRTUAL_ENV"
end
+34
View File
@@ -0,0 +1,34 @@
"""By using execfile(this_file, dict(__file__=this_file)) you will
activate this virtualenv environment.
This can be used when you must use an existing Python interpreter, not
the virtualenv bin/python
"""
try:
__file__
except NameError:
raise AssertionError(
"You must run this like execfile('path/to/activate_this.py', dict(__file__='path/to/activate_this.py'))")
import sys
import os
old_os_path = os.environ['PATH']
os.environ['PATH'] = os.path.dirname(os.path.abspath(__file__)) + os.pathsep + old_os_path
base = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
if sys.platform == 'win32':
site_packages = os.path.join(base, 'Lib', 'site-packages')
else:
site_packages = os.path.join(base, 'lib', 'python%s' % sys.version[:3], 'site-packages')
prev_sys_path = list(sys.path)
import site
site.addsitedir(site_packages)
sys.real_prefix = sys.prefix
sys.prefix = base
# Move the added items to the front of the path:
new_sys_path = []
for item in list(sys.path):
if item not in prev_sys_path:
new_sys_path.append(item)
sys.path.remove(item)
sys.path[:0] = new_sys_path
+11
View File
@@ -0,0 +1,11 @@
#!/home/pi/OctoPrint-TFG/venv/bin/python2
# -*- coding: utf-8 -*-
import re
import sys
from setuptools.command.easy_install import main
if __name__ == '__main__':
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
sys.exit(main())
+11
View File
@@ -0,0 +1,11 @@
#!/home/pi/OctoPrint-TFG/venv/bin/python2
# -*- coding: utf-8 -*-
import re
import sys
from setuptools.command.easy_install import main
if __name__ == '__main__':
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
sys.exit(main())
+4
View File
@@ -0,0 +1,4 @@
#!/home/pi/OctoPrint-TFG/venv/bin/python
# EASY-INSTALL-SCRIPT: 'pyserial==2.7','miniterm.py'
__requires__ = 'pyserial==2.7'
__import__('pkg_resources').run_script('pyserial==2.7', 'miniterm.py')
+4
View File
@@ -0,0 +1,4 @@
#!/home/pi/OctoPrint-TFG/venv/bin/python
# EASY-INSTALL-SCRIPT: 'netaddr==0.7.17','netaddr'
__requires__ = 'netaddr==0.7.17'
__import__('pkg_resources').run_script('netaddr==0.7.17', 'netaddr')
+10
View File
@@ -0,0 +1,10 @@
#!/home/pi/OctoPrint-TFG/venv/bin/python
# EASY-INSTALL-ENTRY-SCRIPT: 'OctoPrint==1.2.8','console_scripts','octoprint'
__requires__ = 'OctoPrint==1.2.8'
import sys
from pkg_resources import load_entry_point
if __name__ == '__main__':
sys.exit(
load_entry_point('OctoPrint==1.2.8', 'console_scripts', 'octoprint')()
)
Executable
+11
View File
@@ -0,0 +1,11 @@
#!/home/pi/OctoPrint-TFG/venv/bin/python2
# -*- coding: utf-8 -*-
import re
import sys
from pip import main
if __name__ == '__main__':
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
sys.exit(main())
Executable
+11
View File
@@ -0,0 +1,11 @@
#!/home/pi/OctoPrint-TFG/venv/bin/python2
# -*- coding: utf-8 -*-
import re
import sys
from pip import main
if __name__ == '__main__':
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
sys.exit(main())
+11
View File
@@ -0,0 +1,11 @@
#!/home/pi/OctoPrint-TFG/venv/bin/python2
# -*- coding: utf-8 -*-
import re
import sys
from pip import main
if __name__ == '__main__':
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
sys.exit(main())
+10
View File
@@ -0,0 +1,10 @@
#!/home/pi/OctoPrint-TFG/venv/bin/python
# EASY-INSTALL-ENTRY-SCRIPT: 'pkginfo==1.2.1','console_scripts','pkginfo'
__requires__ = 'pkginfo==1.2.1'
import sys
from pkg_resources import load_entry_point
if __name__ == '__main__':
sys.exit(
load_entry_point('pkginfo==1.2.1', 'console_scripts', 'pkginfo')()
)
+10
View File
@@ -0,0 +1,10 @@
#!/home/pi/OctoPrint-TFG/venv/bin/python
# EASY-INSTALL-ENTRY-SCRIPT: 'Babel==2.2.0','console_scripts','pybabel'
__requires__ = 'Babel==2.2.0'
import sys
from pkg_resources import load_entry_point
if __name__ == '__main__':
sys.exit(
load_entry_point('Babel==2.2.0', 'console_scripts', 'pybabel')()
)
+10
View File
@@ -0,0 +1,10 @@
#!/home/pi/OctoPrint-TFG/venv/bin/python
# EASY-INSTALL-ENTRY-SCRIPT: 'rsa==3.2','console_scripts','pyrsa-decrypt'
__requires__ = 'rsa==3.2'
import sys
from pkg_resources import load_entry_point
if __name__ == '__main__':
sys.exit(
load_entry_point('rsa==3.2', 'console_scripts', 'pyrsa-decrypt')()
)
+10
View File
@@ -0,0 +1,10 @@
#!/home/pi/OctoPrint-TFG/venv/bin/python
# EASY-INSTALL-ENTRY-SCRIPT: 'rsa==3.2','console_scripts','pyrsa-decrypt-bigfile'
__requires__ = 'rsa==3.2'
import sys
from pkg_resources import load_entry_point
if __name__ == '__main__':
sys.exit(
load_entry_point('rsa==3.2', 'console_scripts', 'pyrsa-decrypt-bigfile')()
)
+10
View File
@@ -0,0 +1,10 @@
#!/home/pi/OctoPrint-TFG/venv/bin/python
# EASY-INSTALL-ENTRY-SCRIPT: 'rsa==3.2','console_scripts','pyrsa-encrypt'
__requires__ = 'rsa==3.2'
import sys
from pkg_resources import load_entry_point
if __name__ == '__main__':
sys.exit(
load_entry_point('rsa==3.2', 'console_scripts', 'pyrsa-encrypt')()
)
+10
View File
@@ -0,0 +1,10 @@
#!/home/pi/OctoPrint-TFG/venv/bin/python
# EASY-INSTALL-ENTRY-SCRIPT: 'rsa==3.2','console_scripts','pyrsa-encrypt-bigfile'
__requires__ = 'rsa==3.2'
import sys
from pkg_resources import load_entry_point
if __name__ == '__main__':
sys.exit(
load_entry_point('rsa==3.2', 'console_scripts', 'pyrsa-encrypt-bigfile')()
)
+10
View File
@@ -0,0 +1,10 @@
#!/home/pi/OctoPrint-TFG/venv/bin/python
# EASY-INSTALL-ENTRY-SCRIPT: 'rsa==3.2','console_scripts','pyrsa-keygen'
__requires__ = 'rsa==3.2'
import sys
from pkg_resources import load_entry_point
if __name__ == '__main__':
sys.exit(
load_entry_point('rsa==3.2', 'console_scripts', 'pyrsa-keygen')()
)
+10
View File
@@ -0,0 +1,10 @@
#!/home/pi/OctoPrint-TFG/venv/bin/python
# EASY-INSTALL-ENTRY-SCRIPT: 'rsa==3.2','console_scripts','pyrsa-priv2pub'
__requires__ = 'rsa==3.2'
import sys
from pkg_resources import load_entry_point
if __name__ == '__main__':
sys.exit(
load_entry_point('rsa==3.2', 'console_scripts', 'pyrsa-priv2pub')()
)
+10
View File
@@ -0,0 +1,10 @@
#!/home/pi/OctoPrint-TFG/venv/bin/python
# EASY-INSTALL-ENTRY-SCRIPT: 'rsa==3.2','console_scripts','pyrsa-sign'
__requires__ = 'rsa==3.2'
import sys
from pkg_resources import load_entry_point
if __name__ == '__main__':
sys.exit(
load_entry_point('rsa==3.2', 'console_scripts', 'pyrsa-sign')()
)
+10
View File
@@ -0,0 +1,10 @@
#!/home/pi/OctoPrint-TFG/venv/bin/python
# EASY-INSTALL-ENTRY-SCRIPT: 'rsa==3.2','console_scripts','pyrsa-verify'
__requires__ = 'rsa==3.2'
import sys
from pkg_resources import load_entry_point
if __name__ == '__main__':
sys.exit(
load_entry_point('rsa==3.2', 'console_scripts', 'pyrsa-verify')()
)
+1
View File
@@ -0,0 +1 @@
python2
BIN
View File
Binary file not shown.
+1
View File
@@ -0,0 +1 @@
python2
+10
View File
@@ -0,0 +1,10 @@
#!/home/pi/OctoPrint-TFG/venv/bin/python
# EASY-INSTALL-ENTRY-SCRIPT: 'watchdog==0.8.3','console_scripts','watchmedo'
__requires__ = 'watchdog==0.8.3'
import sys
from pkg_resources import load_entry_point
if __name__ == '__main__':
sys.exit(
load_entry_point('watchdog==0.8.3', 'console_scripts', 'watchmedo')()
)
+10
View File
@@ -0,0 +1,10 @@
#!/home/pi/OctoPrint-TFG/venv/bin/python
# EASY-INSTALL-ENTRY-SCRIPT: 'webassets==0.11.1','console_scripts','webassets'
__requires__ = 'webassets==0.11.1'
import sys
from pkg_resources import load_entry_point
if __name__ == '__main__':
sys.exit(
load_entry_point('webassets==0.11.1', 'console_scripts', 'webassets')()
)
+1
View File
@@ -0,0 +1 @@
/usr/include/python2.7
+1
View File
@@ -0,0 +1 @@
/usr/lib/python2.7/UserDict.py
+1
View File
@@ -0,0 +1 @@
/usr/lib/python2.7/_abcoll.py
+1
View File
@@ -0,0 +1 @@
/usr/lib/python2.7/_weakrefset.py
+1
View File
@@ -0,0 +1 @@
/usr/lib/python2.7/abc.py
+1
View File
@@ -0,0 +1 @@
/usr/lib/python2.7/codecs.py
+1
View File
@@ -0,0 +1 @@
/usr/lib/python2.7/copy_reg.py
+101
View File
@@ -0,0 +1,101 @@
import os
import sys
import warnings
import imp
import opcode # opcode is not a virtualenv module, so we can use it to find the stdlib
# Important! To work on pypy, this must be a module that resides in the
# lib-python/modified-x.y.z directory
dirname = os.path.dirname
distutils_path = os.path.join(os.path.dirname(opcode.__file__), 'distutils')
if os.path.normpath(distutils_path) == os.path.dirname(os.path.normpath(__file__)):
warnings.warn(
"The virtualenv distutils package at %s appears to be in the same location as the system distutils?")
else:
__path__.insert(0, distutils_path)
real_distutils = imp.load_module("_virtualenv_distutils", None, distutils_path, ('', '', imp.PKG_DIRECTORY))
# Copy the relevant attributes
try:
__revision__ = real_distutils.__revision__
except AttributeError:
pass
__version__ = real_distutils.__version__
from distutils import dist, sysconfig
try:
basestring
except NameError:
basestring = str
## patch build_ext (distutils doesn't know how to get the libs directory
## path on windows - it hardcodes the paths around the patched sys.prefix)
if sys.platform == 'win32':
from distutils.command.build_ext import build_ext as old_build_ext
class build_ext(old_build_ext):
def finalize_options (self):
if self.library_dirs is None:
self.library_dirs = []
elif isinstance(self.library_dirs, basestring):
self.library_dirs = self.library_dirs.split(os.pathsep)
self.library_dirs.insert(0, os.path.join(sys.real_prefix, "Libs"))
old_build_ext.finalize_options(self)
from distutils.command import build_ext as build_ext_module
build_ext_module.build_ext = build_ext
## distutils.dist patches:
old_find_config_files = dist.Distribution.find_config_files
def find_config_files(self):
found = old_find_config_files(self)
system_distutils = os.path.join(distutils_path, 'distutils.cfg')
#if os.path.exists(system_distutils):
# found.insert(0, system_distutils)
# What to call the per-user config file
if os.name == 'posix':
user_filename = ".pydistutils.cfg"
else:
user_filename = "pydistutils.cfg"
user_filename = os.path.join(sys.prefix, user_filename)
if os.path.isfile(user_filename):
for item in list(found):
if item.endswith('pydistutils.cfg'):
found.remove(item)
found.append(user_filename)
return found
dist.Distribution.find_config_files = find_config_files
## distutils.sysconfig patches:
old_get_python_inc = sysconfig.get_python_inc
def sysconfig_get_python_inc(plat_specific=0, prefix=None):
if prefix is None:
prefix = sys.real_prefix
return old_get_python_inc(plat_specific, prefix)
sysconfig_get_python_inc.__doc__ = old_get_python_inc.__doc__
sysconfig.get_python_inc = sysconfig_get_python_inc
old_get_python_lib = sysconfig.get_python_lib
def sysconfig_get_python_lib(plat_specific=0, standard_lib=0, prefix=None):
if standard_lib and prefix is None:
prefix = sys.real_prefix
return old_get_python_lib(plat_specific, standard_lib, prefix)
sysconfig_get_python_lib.__doc__ = old_get_python_lib.__doc__
sysconfig.get_python_lib = sysconfig_get_python_lib
old_get_config_vars = sysconfig.get_config_vars
def sysconfig_get_config_vars(*args):
real_vars = old_get_config_vars(*args)
if sys.platform == 'win32':
lib_dir = os.path.join(sys.real_prefix, "libs")
if isinstance(real_vars, dict) and 'LIBDIR' not in real_vars:
real_vars['LIBDIR'] = lib_dir # asked for all
elif isinstance(real_vars, list) and 'LIBDIR' in args:
real_vars = real_vars + [lib_dir] # asked for list
return real_vars
sysconfig_get_config_vars.__doc__ = old_get_config_vars.__doc__
sysconfig.get_config_vars = sysconfig_get_config_vars
@@ -0,0 +1,6 @@
# This is a config file local to this virtualenv installation
# You may include options that will be used by all distutils commands,
# and by easy_install. For instance:
#
# [easy_install]
# find_links = http://mylocalsite
+1
View File
@@ -0,0 +1 @@
/usr/lib/python2.7/encodings
+1
View File
@@ -0,0 +1 @@
/usr/lib/python2.7/fnmatch.py
+1
View File
@@ -0,0 +1 @@
/usr/lib/python2.7/genericpath.py
+1
View File
@@ -0,0 +1 @@
/usr/lib/python2.7/lib-dynload
+1
View File
@@ -0,0 +1 @@
/usr/lib/python2.7/linecache.py
+1
View File
@@ -0,0 +1 @@
/usr/lib/python2.7/locale.py
+1
View File
@@ -0,0 +1 @@
/usr/lib/python2.7/ntpath.py
+1
View File
@@ -0,0 +1 @@
/usr
+1
View File
@@ -0,0 +1 @@
/usr/lib/python2.7/os.py
+1
View File
@@ -0,0 +1 @@
/usr/lib/python2.7/posixpath.py
+1
View File
@@ -0,0 +1 @@
/usr/lib/python2.7/re.py
@@ -0,0 +1,23 @@
Metadata-Version: 1.1
Name: Babel
Version: 2.2.0
Summary: Internationalization utilities
Home-page: http://babel.pocoo.org/
Author: Armin Ronacher
Author-email: armin.ronacher@active-4.com
License: BSD
Description: A collection of tools for internationalizing Python applications.
Platform: UNKNOWN
Classifier: Development Status :: 5 - Production/Stable
Classifier: Environment :: Web Environment
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: BSD License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 2.6
Classifier: Programming Language :: Python :: 2.7
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.3
Classifier: Programming Language :: Python :: 3.4
Classifier: Programming Language :: Python :: 3.5
Classifier: Topic :: Software Development :: Libraries :: Python Modules
@@ -0,0 +1,827 @@
AUTHORS
CHANGES
LICENSE
MANIFEST.in
Makefile
conftest.py
setup.cfg
setup.py
tox.ini
Babel.egg-info/PKG-INFO
Babel.egg-info/SOURCES.txt
Babel.egg-info/dependency_links.txt
Babel.egg-info/entry_points.txt
Babel.egg-info/not-zip-safe
Babel.egg-info/requires.txt
Babel.egg-info/top_level.txt
babel/__init__.py
babel/_compat.py
babel/core.py
babel/dates.py
babel/global.dat
babel/lists.py
babel/localedata.py
babel/numbers.py
babel/plural.py
babel/support.py
babel/util.py
babel/locale-data/af.dat
babel/locale-data/af_NA.dat
babel/locale-data/af_ZA.dat
babel/locale-data/agq.dat
babel/locale-data/agq_CM.dat
babel/locale-data/ak.dat
babel/locale-data/ak_GH.dat
babel/locale-data/am.dat
babel/locale-data/am_ET.dat
babel/locale-data/ar.dat
babel/locale-data/ar_001.dat
babel/locale-data/ar_AE.dat
babel/locale-data/ar_BH.dat
babel/locale-data/ar_DJ.dat
babel/locale-data/ar_DZ.dat
babel/locale-data/ar_EG.dat
babel/locale-data/ar_EH.dat
babel/locale-data/ar_ER.dat
babel/locale-data/ar_IL.dat
babel/locale-data/ar_IQ.dat
babel/locale-data/ar_JO.dat
babel/locale-data/ar_KM.dat
babel/locale-data/ar_KW.dat
babel/locale-data/ar_LB.dat
babel/locale-data/ar_LY.dat
babel/locale-data/ar_MA.dat
babel/locale-data/ar_MR.dat
babel/locale-data/ar_OM.dat
babel/locale-data/ar_PS.dat
babel/locale-data/ar_QA.dat
babel/locale-data/ar_SA.dat
babel/locale-data/ar_SD.dat
babel/locale-data/ar_SO.dat
babel/locale-data/ar_SS.dat
babel/locale-data/ar_SY.dat
babel/locale-data/ar_TD.dat
babel/locale-data/ar_TN.dat
babel/locale-data/ar_YE.dat
babel/locale-data/as.dat
babel/locale-data/as_IN.dat
babel/locale-data/asa.dat
babel/locale-data/asa_TZ.dat
babel/locale-data/ast.dat
babel/locale-data/ast_ES.dat
babel/locale-data/az.dat
babel/locale-data/az_Cyrl.dat
babel/locale-data/az_Cyrl_AZ.dat
babel/locale-data/az_Latn.dat
babel/locale-data/az_Latn_AZ.dat
babel/locale-data/bas.dat
babel/locale-data/bas_CM.dat
babel/locale-data/be.dat
babel/locale-data/be_BY.dat
babel/locale-data/bem.dat
babel/locale-data/bem_ZM.dat
babel/locale-data/bez.dat
babel/locale-data/bez_TZ.dat
babel/locale-data/bg.dat
babel/locale-data/bg_BG.dat
babel/locale-data/bm.dat
babel/locale-data/bm_ML.dat
babel/locale-data/bn.dat
babel/locale-data/bn_BD.dat
babel/locale-data/bn_IN.dat
babel/locale-data/bo.dat
babel/locale-data/bo_CN.dat
babel/locale-data/bo_IN.dat
babel/locale-data/br.dat
babel/locale-data/br_FR.dat
babel/locale-data/brx.dat
babel/locale-data/brx_IN.dat
babel/locale-data/bs.dat
babel/locale-data/bs_Cyrl.dat
babel/locale-data/bs_Cyrl_BA.dat
babel/locale-data/bs_Latn.dat
babel/locale-data/bs_Latn_BA.dat
babel/locale-data/ca.dat
babel/locale-data/ca_AD.dat
babel/locale-data/ca_ES.dat
babel/locale-data/ca_ES_VALENCIA.dat
babel/locale-data/ca_FR.dat
babel/locale-data/ca_IT.dat
babel/locale-data/ce.dat
babel/locale-data/ce_RU.dat
babel/locale-data/cgg.dat
babel/locale-data/cgg_UG.dat
babel/locale-data/chr.dat
babel/locale-data/chr_US.dat
babel/locale-data/ckb.dat
babel/locale-data/ckb_IQ.dat
babel/locale-data/ckb_IR.dat
babel/locale-data/cs.dat
babel/locale-data/cs_CZ.dat
babel/locale-data/cu.dat
babel/locale-data/cu_RU.dat
babel/locale-data/cy.dat
babel/locale-data/cy_GB.dat
babel/locale-data/da.dat
babel/locale-data/da_DK.dat
babel/locale-data/da_GL.dat
babel/locale-data/dav.dat
babel/locale-data/dav_KE.dat
babel/locale-data/de.dat
babel/locale-data/de_AT.dat
babel/locale-data/de_BE.dat
babel/locale-data/de_CH.dat
babel/locale-data/de_DE.dat
babel/locale-data/de_LI.dat
babel/locale-data/de_LU.dat
babel/locale-data/dje.dat
babel/locale-data/dje_NE.dat
babel/locale-data/dsb.dat
babel/locale-data/dsb_DE.dat
babel/locale-data/dua.dat
babel/locale-data/dua_CM.dat
babel/locale-data/dyo.dat
babel/locale-data/dyo_SN.dat
babel/locale-data/dz.dat
babel/locale-data/dz_BT.dat
babel/locale-data/ebu.dat
babel/locale-data/ebu_KE.dat
babel/locale-data/ee.dat
babel/locale-data/ee_GH.dat
babel/locale-data/ee_TG.dat
babel/locale-data/el.dat
babel/locale-data/el_CY.dat
babel/locale-data/el_GR.dat
babel/locale-data/en.dat
babel/locale-data/en_001.dat
babel/locale-data/en_150.dat
babel/locale-data/en_AG.dat
babel/locale-data/en_AI.dat
babel/locale-data/en_AS.dat
babel/locale-data/en_AT.dat
babel/locale-data/en_AU.dat
babel/locale-data/en_BB.dat
babel/locale-data/en_BE.dat
babel/locale-data/en_BI.dat
babel/locale-data/en_BM.dat
babel/locale-data/en_BS.dat
babel/locale-data/en_BW.dat
babel/locale-data/en_BZ.dat
babel/locale-data/en_CA.dat
babel/locale-data/en_CC.dat
babel/locale-data/en_CH.dat
babel/locale-data/en_CK.dat
babel/locale-data/en_CM.dat
babel/locale-data/en_CX.dat
babel/locale-data/en_CY.dat
babel/locale-data/en_DE.dat
babel/locale-data/en_DG.dat
babel/locale-data/en_DK.dat
babel/locale-data/en_DM.dat
babel/locale-data/en_ER.dat
babel/locale-data/en_FI.dat
babel/locale-data/en_FJ.dat
babel/locale-data/en_FK.dat
babel/locale-data/en_FM.dat
babel/locale-data/en_GB.dat
babel/locale-data/en_GD.dat
babel/locale-data/en_GG.dat
babel/locale-data/en_GH.dat
babel/locale-data/en_GI.dat
babel/locale-data/en_GM.dat
babel/locale-data/en_GU.dat
babel/locale-data/en_GY.dat
babel/locale-data/en_HK.dat
babel/locale-data/en_IE.dat
babel/locale-data/en_IL.dat
babel/locale-data/en_IM.dat
babel/locale-data/en_IN.dat
babel/locale-data/en_IO.dat
babel/locale-data/en_JE.dat
babel/locale-data/en_JM.dat
babel/locale-data/en_KE.dat
babel/locale-data/en_KI.dat
babel/locale-data/en_KN.dat
babel/locale-data/en_KY.dat
babel/locale-data/en_LC.dat
babel/locale-data/en_LR.dat
babel/locale-data/en_LS.dat
babel/locale-data/en_MG.dat
babel/locale-data/en_MH.dat
babel/locale-data/en_MO.dat
babel/locale-data/en_MP.dat
babel/locale-data/en_MS.dat
babel/locale-data/en_MT.dat
babel/locale-data/en_MU.dat
babel/locale-data/en_MW.dat
babel/locale-data/en_MY.dat
babel/locale-data/en_NA.dat
babel/locale-data/en_NF.dat
babel/locale-data/en_NG.dat
babel/locale-data/en_NL.dat
babel/locale-data/en_NR.dat
babel/locale-data/en_NU.dat
babel/locale-data/en_NZ.dat
babel/locale-data/en_PG.dat
babel/locale-data/en_PH.dat
babel/locale-data/en_PK.dat
babel/locale-data/en_PN.dat
babel/locale-data/en_PR.dat
babel/locale-data/en_PW.dat
babel/locale-data/en_RW.dat
babel/locale-data/en_SB.dat
babel/locale-data/en_SC.dat
babel/locale-data/en_SD.dat
babel/locale-data/en_SE.dat
babel/locale-data/en_SG.dat
babel/locale-data/en_SH.dat
babel/locale-data/en_SI.dat
babel/locale-data/en_SL.dat
babel/locale-data/en_SS.dat
babel/locale-data/en_SX.dat
babel/locale-data/en_SZ.dat
babel/locale-data/en_TC.dat
babel/locale-data/en_TK.dat
babel/locale-data/en_TO.dat
babel/locale-data/en_TT.dat
babel/locale-data/en_TV.dat
babel/locale-data/en_TZ.dat
babel/locale-data/en_UG.dat
babel/locale-data/en_UM.dat
babel/locale-data/en_US.dat
babel/locale-data/en_US_POSIX.dat
babel/locale-data/en_VC.dat
babel/locale-data/en_VG.dat
babel/locale-data/en_VI.dat
babel/locale-data/en_VU.dat
babel/locale-data/en_WS.dat
babel/locale-data/en_ZA.dat
babel/locale-data/en_ZM.dat
babel/locale-data/en_ZW.dat
babel/locale-data/eo.dat
babel/locale-data/eo_001.dat
babel/locale-data/es.dat
babel/locale-data/es_419.dat
babel/locale-data/es_AR.dat
babel/locale-data/es_BO.dat
babel/locale-data/es_CL.dat
babel/locale-data/es_CO.dat
babel/locale-data/es_CR.dat
babel/locale-data/es_CU.dat
babel/locale-data/es_DO.dat
babel/locale-data/es_EA.dat
babel/locale-data/es_EC.dat
babel/locale-data/es_ES.dat
babel/locale-data/es_GQ.dat
babel/locale-data/es_GT.dat
babel/locale-data/es_HN.dat
babel/locale-data/es_IC.dat
babel/locale-data/es_MX.dat
babel/locale-data/es_NI.dat
babel/locale-data/es_PA.dat
babel/locale-data/es_PE.dat
babel/locale-data/es_PH.dat
babel/locale-data/es_PR.dat
babel/locale-data/es_PY.dat
babel/locale-data/es_SV.dat
babel/locale-data/es_US.dat
babel/locale-data/es_UY.dat
babel/locale-data/es_VE.dat
babel/locale-data/et.dat
babel/locale-data/et_EE.dat
babel/locale-data/eu.dat
babel/locale-data/eu_ES.dat
babel/locale-data/ewo.dat
babel/locale-data/ewo_CM.dat
babel/locale-data/fa.dat
babel/locale-data/fa_AF.dat
babel/locale-data/fa_IR.dat
babel/locale-data/ff.dat
babel/locale-data/ff_CM.dat
babel/locale-data/ff_GN.dat
babel/locale-data/ff_MR.dat
babel/locale-data/ff_SN.dat
babel/locale-data/fi.dat
babel/locale-data/fi_FI.dat
babel/locale-data/fil.dat
babel/locale-data/fil_PH.dat
babel/locale-data/fo.dat
babel/locale-data/fo_DK.dat
babel/locale-data/fo_FO.dat
babel/locale-data/fr.dat
babel/locale-data/fr_BE.dat
babel/locale-data/fr_BF.dat
babel/locale-data/fr_BI.dat
babel/locale-data/fr_BJ.dat
babel/locale-data/fr_BL.dat
babel/locale-data/fr_CA.dat
babel/locale-data/fr_CD.dat
babel/locale-data/fr_CF.dat
babel/locale-data/fr_CG.dat
babel/locale-data/fr_CH.dat
babel/locale-data/fr_CI.dat
babel/locale-data/fr_CM.dat
babel/locale-data/fr_DJ.dat
babel/locale-data/fr_DZ.dat
babel/locale-data/fr_FR.dat
babel/locale-data/fr_GA.dat
babel/locale-data/fr_GF.dat
babel/locale-data/fr_GN.dat
babel/locale-data/fr_GP.dat
babel/locale-data/fr_GQ.dat
babel/locale-data/fr_HT.dat
babel/locale-data/fr_KM.dat
babel/locale-data/fr_LU.dat
babel/locale-data/fr_MA.dat
babel/locale-data/fr_MC.dat
babel/locale-data/fr_MF.dat
babel/locale-data/fr_MG.dat
babel/locale-data/fr_ML.dat
babel/locale-data/fr_MQ.dat
babel/locale-data/fr_MR.dat
babel/locale-data/fr_MU.dat
babel/locale-data/fr_NC.dat
babel/locale-data/fr_NE.dat
babel/locale-data/fr_PF.dat
babel/locale-data/fr_PM.dat
babel/locale-data/fr_RE.dat
babel/locale-data/fr_RW.dat
babel/locale-data/fr_SC.dat
babel/locale-data/fr_SN.dat
babel/locale-data/fr_SY.dat
babel/locale-data/fr_TD.dat
babel/locale-data/fr_TG.dat
babel/locale-data/fr_TN.dat
babel/locale-data/fr_VU.dat
babel/locale-data/fr_WF.dat
babel/locale-data/fr_YT.dat
babel/locale-data/fur.dat
babel/locale-data/fur_IT.dat
babel/locale-data/fy.dat
babel/locale-data/fy_NL.dat
babel/locale-data/ga.dat
babel/locale-data/ga_IE.dat
babel/locale-data/gd.dat
babel/locale-data/gd_GB.dat
babel/locale-data/gl.dat
babel/locale-data/gl_ES.dat
babel/locale-data/gsw.dat
babel/locale-data/gsw_CH.dat
babel/locale-data/gsw_FR.dat
babel/locale-data/gsw_LI.dat
babel/locale-data/gu.dat
babel/locale-data/gu_IN.dat
babel/locale-data/guz.dat
babel/locale-data/guz_KE.dat
babel/locale-data/gv.dat
babel/locale-data/gv_IM.dat
babel/locale-data/ha.dat
babel/locale-data/ha_GH.dat
babel/locale-data/ha_NE.dat
babel/locale-data/ha_NG.dat
babel/locale-data/haw.dat
babel/locale-data/haw_US.dat
babel/locale-data/he.dat
babel/locale-data/he_IL.dat
babel/locale-data/hi.dat
babel/locale-data/hi_IN.dat
babel/locale-data/hr.dat
babel/locale-data/hr_BA.dat
babel/locale-data/hr_HR.dat
babel/locale-data/hsb.dat
babel/locale-data/hsb_DE.dat
babel/locale-data/hu.dat
babel/locale-data/hu_HU.dat
babel/locale-data/hy.dat
babel/locale-data/hy_AM.dat
babel/locale-data/id.dat
babel/locale-data/id_ID.dat
babel/locale-data/ig.dat
babel/locale-data/ig_NG.dat
babel/locale-data/ii.dat
babel/locale-data/ii_CN.dat
babel/locale-data/is.dat
babel/locale-data/is_IS.dat
babel/locale-data/it.dat
babel/locale-data/it_CH.dat
babel/locale-data/it_IT.dat
babel/locale-data/it_SM.dat
babel/locale-data/ja.dat
babel/locale-data/ja_JP.dat
babel/locale-data/jgo.dat
babel/locale-data/jgo_CM.dat
babel/locale-data/jmc.dat
babel/locale-data/jmc_TZ.dat
babel/locale-data/ka.dat
babel/locale-data/ka_GE.dat
babel/locale-data/kab.dat
babel/locale-data/kab_DZ.dat
babel/locale-data/kam.dat
babel/locale-data/kam_KE.dat
babel/locale-data/kde.dat
babel/locale-data/kde_TZ.dat
babel/locale-data/kea.dat
babel/locale-data/kea_CV.dat
babel/locale-data/khq.dat
babel/locale-data/khq_ML.dat
babel/locale-data/ki.dat
babel/locale-data/ki_KE.dat
babel/locale-data/kk.dat
babel/locale-data/kk_KZ.dat
babel/locale-data/kkj.dat
babel/locale-data/kkj_CM.dat
babel/locale-data/kl.dat
babel/locale-data/kl_GL.dat
babel/locale-data/kln.dat
babel/locale-data/kln_KE.dat
babel/locale-data/km.dat
babel/locale-data/km_KH.dat
babel/locale-data/kn.dat
babel/locale-data/kn_IN.dat
babel/locale-data/ko.dat
babel/locale-data/ko_KP.dat
babel/locale-data/ko_KR.dat
babel/locale-data/kok.dat
babel/locale-data/kok_IN.dat
babel/locale-data/ks.dat
babel/locale-data/ks_IN.dat
babel/locale-data/ksb.dat
babel/locale-data/ksb_TZ.dat
babel/locale-data/ksf.dat
babel/locale-data/ksf_CM.dat
babel/locale-data/ksh.dat
babel/locale-data/ksh_DE.dat
babel/locale-data/kw.dat
babel/locale-data/kw_GB.dat
babel/locale-data/ky.dat
babel/locale-data/ky_KG.dat
babel/locale-data/lag.dat
babel/locale-data/lag_TZ.dat
babel/locale-data/lb.dat
babel/locale-data/lb_LU.dat
babel/locale-data/lg.dat
babel/locale-data/lg_UG.dat
babel/locale-data/lkt.dat
babel/locale-data/lkt_US.dat
babel/locale-data/ln.dat
babel/locale-data/ln_AO.dat
babel/locale-data/ln_CD.dat
babel/locale-data/ln_CF.dat
babel/locale-data/ln_CG.dat
babel/locale-data/lo.dat
babel/locale-data/lo_LA.dat
babel/locale-data/lrc.dat
babel/locale-data/lrc_IQ.dat
babel/locale-data/lrc_IR.dat
babel/locale-data/lt.dat
babel/locale-data/lt_LT.dat
babel/locale-data/lu.dat
babel/locale-data/lu_CD.dat
babel/locale-data/luo.dat
babel/locale-data/luo_KE.dat
babel/locale-data/luy.dat
babel/locale-data/luy_KE.dat
babel/locale-data/lv.dat
babel/locale-data/lv_LV.dat
babel/locale-data/mas.dat
babel/locale-data/mas_KE.dat
babel/locale-data/mas_TZ.dat
babel/locale-data/mer.dat
babel/locale-data/mer_KE.dat
babel/locale-data/mfe.dat
babel/locale-data/mfe_MU.dat
babel/locale-data/mg.dat
babel/locale-data/mg_MG.dat
babel/locale-data/mgh.dat
babel/locale-data/mgh_MZ.dat
babel/locale-data/mgo.dat
babel/locale-data/mgo_CM.dat
babel/locale-data/mk.dat
babel/locale-data/mk_MK.dat
babel/locale-data/ml.dat
babel/locale-data/ml_IN.dat
babel/locale-data/mn.dat
babel/locale-data/mn_MN.dat
babel/locale-data/mr.dat
babel/locale-data/mr_IN.dat
babel/locale-data/ms.dat
babel/locale-data/ms_BN.dat
babel/locale-data/ms_MY.dat
babel/locale-data/ms_SG.dat
babel/locale-data/mt.dat
babel/locale-data/mt_MT.dat
babel/locale-data/mua.dat
babel/locale-data/mua_CM.dat
babel/locale-data/my.dat
babel/locale-data/my_MM.dat
babel/locale-data/mzn.dat
babel/locale-data/mzn_IR.dat
babel/locale-data/naq.dat
babel/locale-data/naq_NA.dat
babel/locale-data/nb.dat
babel/locale-data/nb_NO.dat
babel/locale-data/nb_SJ.dat
babel/locale-data/nd.dat
babel/locale-data/nd_ZW.dat
babel/locale-data/ne.dat
babel/locale-data/ne_IN.dat
babel/locale-data/ne_NP.dat
babel/locale-data/nl.dat
babel/locale-data/nl_AW.dat
babel/locale-data/nl_BE.dat
babel/locale-data/nl_BQ.dat
babel/locale-data/nl_CW.dat
babel/locale-data/nl_NL.dat
babel/locale-data/nl_SR.dat
babel/locale-data/nl_SX.dat
babel/locale-data/nmg.dat
babel/locale-data/nmg_CM.dat
babel/locale-data/nn.dat
babel/locale-data/nn_NO.dat
babel/locale-data/nnh.dat
babel/locale-data/nnh_CM.dat
babel/locale-data/nus.dat
babel/locale-data/nus_SS.dat
babel/locale-data/nyn.dat
babel/locale-data/nyn_UG.dat
babel/locale-data/om.dat
babel/locale-data/om_ET.dat
babel/locale-data/om_KE.dat
babel/locale-data/or.dat
babel/locale-data/or_IN.dat
babel/locale-data/os.dat
babel/locale-data/os_GE.dat
babel/locale-data/os_RU.dat
babel/locale-data/pa.dat
babel/locale-data/pa_Arab.dat
babel/locale-data/pa_Arab_PK.dat
babel/locale-data/pa_Guru.dat
babel/locale-data/pa_Guru_IN.dat
babel/locale-data/pl.dat
babel/locale-data/pl_PL.dat
babel/locale-data/prg.dat
babel/locale-data/prg_001.dat
babel/locale-data/ps.dat
babel/locale-data/ps_AF.dat
babel/locale-data/pt.dat
babel/locale-data/pt_AO.dat
babel/locale-data/pt_BR.dat
babel/locale-data/pt_CV.dat
babel/locale-data/pt_GW.dat
babel/locale-data/pt_MO.dat
babel/locale-data/pt_MZ.dat
babel/locale-data/pt_PT.dat
babel/locale-data/pt_ST.dat
babel/locale-data/pt_TL.dat
babel/locale-data/qu.dat
babel/locale-data/qu_BO.dat
babel/locale-data/qu_EC.dat
babel/locale-data/qu_PE.dat
babel/locale-data/rm.dat
babel/locale-data/rm_CH.dat
babel/locale-data/rn.dat
babel/locale-data/rn_BI.dat
babel/locale-data/ro.dat
babel/locale-data/ro_MD.dat
babel/locale-data/ro_RO.dat
babel/locale-data/rof.dat
babel/locale-data/rof_TZ.dat
babel/locale-data/root.dat
babel/locale-data/ru.dat
babel/locale-data/ru_BY.dat
babel/locale-data/ru_KG.dat
babel/locale-data/ru_KZ.dat
babel/locale-data/ru_MD.dat
babel/locale-data/ru_RU.dat
babel/locale-data/ru_UA.dat
babel/locale-data/rw.dat
babel/locale-data/rw_RW.dat
babel/locale-data/rwk.dat
babel/locale-data/rwk_TZ.dat
babel/locale-data/sah.dat
babel/locale-data/sah_RU.dat
babel/locale-data/saq.dat
babel/locale-data/saq_KE.dat
babel/locale-data/sbp.dat
babel/locale-data/sbp_TZ.dat
babel/locale-data/se.dat
babel/locale-data/se_FI.dat
babel/locale-data/se_NO.dat
babel/locale-data/se_SE.dat
babel/locale-data/seh.dat
babel/locale-data/seh_MZ.dat
babel/locale-data/ses.dat
babel/locale-data/ses_ML.dat
babel/locale-data/sg.dat
babel/locale-data/sg_CF.dat
babel/locale-data/shi.dat
babel/locale-data/shi_Latn.dat
babel/locale-data/shi_Latn_MA.dat
babel/locale-data/shi_Tfng.dat
babel/locale-data/shi_Tfng_MA.dat
babel/locale-data/si.dat
babel/locale-data/si_LK.dat
babel/locale-data/sk.dat
babel/locale-data/sk_SK.dat
babel/locale-data/sl.dat
babel/locale-data/sl_SI.dat
babel/locale-data/smn.dat
babel/locale-data/smn_FI.dat
babel/locale-data/sn.dat
babel/locale-data/sn_ZW.dat
babel/locale-data/so.dat
babel/locale-data/so_DJ.dat
babel/locale-data/so_ET.dat
babel/locale-data/so_KE.dat
babel/locale-data/so_SO.dat
babel/locale-data/sq.dat
babel/locale-data/sq_AL.dat
babel/locale-data/sq_MK.dat
babel/locale-data/sq_XK.dat
babel/locale-data/sr.dat
babel/locale-data/sr_Cyrl.dat
babel/locale-data/sr_Cyrl_BA.dat
babel/locale-data/sr_Cyrl_ME.dat
babel/locale-data/sr_Cyrl_RS.dat
babel/locale-data/sr_Cyrl_XK.dat
babel/locale-data/sr_Latn.dat
babel/locale-data/sr_Latn_BA.dat
babel/locale-data/sr_Latn_ME.dat
babel/locale-data/sr_Latn_RS.dat
babel/locale-data/sr_Latn_XK.dat
babel/locale-data/sv.dat
babel/locale-data/sv_AX.dat
babel/locale-data/sv_FI.dat
babel/locale-data/sv_SE.dat
babel/locale-data/sw.dat
babel/locale-data/sw_CD.dat
babel/locale-data/sw_KE.dat
babel/locale-data/sw_TZ.dat
babel/locale-data/sw_UG.dat
babel/locale-data/ta.dat
babel/locale-data/ta_IN.dat
babel/locale-data/ta_LK.dat
babel/locale-data/ta_MY.dat
babel/locale-data/ta_SG.dat
babel/locale-data/te.dat
babel/locale-data/te_IN.dat
babel/locale-data/teo.dat
babel/locale-data/teo_KE.dat
babel/locale-data/teo_UG.dat
babel/locale-data/th.dat
babel/locale-data/th_TH.dat
babel/locale-data/ti.dat
babel/locale-data/ti_ER.dat
babel/locale-data/ti_ET.dat
babel/locale-data/tk.dat
babel/locale-data/tk_TM.dat
babel/locale-data/to.dat
babel/locale-data/to_TO.dat
babel/locale-data/tr.dat
babel/locale-data/tr_CY.dat
babel/locale-data/tr_TR.dat
babel/locale-data/twq.dat
babel/locale-data/twq_NE.dat
babel/locale-data/tzm.dat
babel/locale-data/tzm_MA.dat
babel/locale-data/ug.dat
babel/locale-data/ug_CN.dat
babel/locale-data/uk.dat
babel/locale-data/uk_UA.dat
babel/locale-data/ur.dat
babel/locale-data/ur_IN.dat
babel/locale-data/ur_PK.dat
babel/locale-data/uz.dat
babel/locale-data/uz_Arab.dat
babel/locale-data/uz_Arab_AF.dat
babel/locale-data/uz_Cyrl.dat
babel/locale-data/uz_Cyrl_UZ.dat
babel/locale-data/uz_Latn.dat
babel/locale-data/uz_Latn_UZ.dat
babel/locale-data/vai.dat
babel/locale-data/vai_Latn.dat
babel/locale-data/vai_Latn_LR.dat
babel/locale-data/vai_Vaii.dat
babel/locale-data/vai_Vaii_LR.dat
babel/locale-data/vi.dat
babel/locale-data/vi_VN.dat
babel/locale-data/vo.dat
babel/locale-data/vo_001.dat
babel/locale-data/vun.dat
babel/locale-data/vun_TZ.dat
babel/locale-data/wae.dat
babel/locale-data/wae_CH.dat
babel/locale-data/xog.dat
babel/locale-data/xog_UG.dat
babel/locale-data/yav.dat
babel/locale-data/yav_CM.dat
babel/locale-data/yi.dat
babel/locale-data/yi_001.dat
babel/locale-data/yo.dat
babel/locale-data/yo_BJ.dat
babel/locale-data/yo_NG.dat
babel/locale-data/zgh.dat
babel/locale-data/zgh_MA.dat
babel/locale-data/zh.dat
babel/locale-data/zh_Hans.dat
babel/locale-data/zh_Hans_CN.dat
babel/locale-data/zh_Hans_HK.dat
babel/locale-data/zh_Hans_MO.dat
babel/locale-data/zh_Hans_SG.dat
babel/locale-data/zh_Hant.dat
babel/locale-data/zh_Hant_HK.dat
babel/locale-data/zh_Hant_MO.dat
babel/locale-data/zh_Hant_TW.dat
babel/locale-data/zu.dat
babel/locale-data/zu_ZA.dat
babel/localtime/__init__.py
babel/localtime/_unix.py
babel/localtime/_win32.py
babel/messages/__init__.py
babel/messages/catalog.py
babel/messages/checkers.py
babel/messages/extract.py
babel/messages/frontend.py
babel/messages/jslexer.py
babel/messages/mofile.py
babel/messages/plurals.py
babel/messages/pofile.py
docs/Makefile
docs/changelog.rst
docs/cmdline.rst
docs/conf.py
docs/dates.rst
docs/dev.rst
docs/index.rst
docs/installation.rst
docs/intro.rst
docs/license.rst
docs/locale.rst
docs/make.bat
docs/messages.rst
docs/numbers.rst
docs/setup.rst
docs/support.rst
docs/_static/logo.pdf
docs/_static/logo.png
docs/_static/logo_small.png
docs/_templates/sidebar-about.html
docs/_templates/sidebar-links.html
docs/_templates/sidebar-logo.html
docs/_themes/LICENSE
docs/_themes/README
docs/_themes/babel/layout.html
docs/_themes/babel/relations.html
docs/_themes/babel/theme.conf
docs/_themes/babel/static/babel.css_t
docs/_themes/babel/static/small_babel.css
docs/api/core.rst
docs/api/dates.rst
docs/api/index.rst
docs/api/numbers.rst
docs/api/plural.rst
docs/api/support.rst
docs/api/messages/catalog.rst
docs/api/messages/extract.rst
docs/api/messages/index.rst
docs/api/messages/mofile.rst
docs/api/messages/pofile.rst
scripts/download_import_cldr.py
scripts/dump_data.py
scripts/dump_global.py
scripts/import_cldr.py
scripts/make-release.py
tests/__init__.py
tests/conftest.py
tests/test_core.py
tests/test_dates.py
tests/test_lists.py
tests/test_localedata.py
tests/test_numbers.py
tests/test_plural.py
tests/test_support.py
tests/test_util.py
tests/messages/__init__.py
tests/messages/test_catalog.py
tests/messages/test_checkers.py
tests/messages/test_extract.py
tests/messages/test_frontend.py
tests/messages/test_jslexer.py
tests/messages/test_mofile.py
tests/messages/test_plurals.py
tests/messages/test_pofile.py
tests/messages/data/mapping.cfg
tests/messages/data/setup.cfg
tests/messages/data/setup.py
tests/messages/data/project/__init__.py
tests/messages/data/project/file1.py
tests/messages/data/project/file2.py
tests/messages/data/project/i18n/messages.pot
tests/messages/data/project/i18n/messages_non_fuzzy.pot
tests/messages/data/project/i18n/de/LC_MESSAGES/messages.mo
tests/messages/data/project/i18n/de/LC_MESSAGES/messages.po
tests/messages/data/project/i18n/de_DE/LC_MESSAGES/messages.po
tests/messages/data/project/i18n/ru_RU/LC_MESSAGES/messages.po
tests/messages/data/project/ignored/a_test_file.txt
tests/messages/data/project/ignored/an_example.txt
tests/messages/data/project/ignored/this_wont_normally_be_here.py
@@ -0,0 +1,22 @@
[console_scripts]
pybabel = babel.messages.frontend:main
[distutils.commands]
compile_catalog = babel.messages.frontend:compile_catalog
extract_messages = babel.messages.frontend:extract_messages
init_catalog = babel.messages.frontend:init_catalog
update_catalog = babel.messages.frontend:update_catalog
[distutils.setup_keywords]
message_extractors = babel.messages.frontend:check_message_extractors
[babel.checkers]
num_plurals = babel.messages.checkers:num_plurals
python_format = babel.messages.checkers:python_format
[babel.extractors]
ignore = babel.messages.extract:extract_nothing
python = babel.messages.extract:extract_python
javascript = babel.messages.extract:extract_javascript
@@ -0,0 +1,24 @@
# -*- coding: utf-8 -*-
"""
babel
~~~~~
Integrated collection of utilities that assist in internationalizing and
localizing applications.
This package is basically composed of two major parts:
* tools to build and work with ``gettext`` message catalogs
* a Python interface to the CLDR (Common Locale Data Repository), providing
access to various locale display names, localized number and date
formatting, etc.
:copyright: (c) 2013 by the Babel Team.
:license: BSD, see LICENSE for more details.
"""
from babel.core import UnknownLocaleError, Locale, default_locale, \
negotiate_locale, parse_locale, get_locale_identifier
__version__ = '2.2.0'
@@ -0,0 +1,76 @@
import sys
import array
PY2 = sys.version_info[0] == 2
_identity = lambda x: x
if not PY2:
text_type = str
string_types = (str,)
integer_types = (int, )
unichr = chr
text_to_native = lambda s, enc: s
iterkeys = lambda d: iter(d.keys())
itervalues = lambda d: iter(d.values())
iteritems = lambda d: iter(d.items())
from io import StringIO, BytesIO
import pickle
izip = zip
imap = map
range_type = range
cmp = lambda a, b: (a > b) - (a < b)
array_tobytes = array.array.tobytes
else:
text_type = unicode
string_types = (str, unicode)
integer_types = (int, long)
text_to_native = lambda s, enc: s.encode(enc)
unichr = unichr
iterkeys = lambda d: d.iterkeys()
itervalues = lambda d: d.itervalues()
iteritems = lambda d: d.iteritems()
from cStringIO import StringIO as BytesIO
from StringIO import StringIO
import cPickle as pickle
from itertools import imap
from itertools import izip
range_type = xrange
cmp = cmp
array_tobytes = array.array.tostring
number_types = integer_types + (float,)
#
# Use cdecimal when available
#
from decimal import (Decimal as _dec,
InvalidOperation as _invop,
ROUND_HALF_EVEN as _RHE)
try:
from cdecimal import (Decimal as _cdec,
InvalidOperation as _cinvop,
ROUND_HALF_EVEN as _CRHE)
Decimal = _cdec
InvalidOperation = (_invop, _cinvop)
ROUND_HALF_EVEN = _CRHE
except ImportError:
Decimal = _dec
InvalidOperation = _invop
ROUND_HALF_EVEN = _RHE
@@ -0,0 +1,978 @@
# -*- coding: utf-8 -*-
"""
babel.core
~~~~~~~~~~
Core locale representation and locale data access.
:copyright: (c) 2013 by the Babel Team.
:license: BSD, see LICENSE for more details.
"""
import os
from babel import localedata
from babel._compat import pickle, string_types
from babel.plural import PluralRule
__all__ = ['UnknownLocaleError', 'Locale', 'default_locale', 'negotiate_locale',
'parse_locale']
_global_data = None
_default_plural_rule = PluralRule({})
def _raise_no_data_error():
raise RuntimeError('The babel data files are not available. '
'This usually happens because you are using '
'a source checkout from Babel and you did '
'not build the data files. Just make sure '
'to run "python setup.py import_cldr" before '
'installing the library.')
def get_global(key):
"""Return the dictionary for the given key in the global data.
The global data is stored in the ``babel/global.dat`` file and contains
information independent of individual locales.
>>> get_global('zone_aliases')['UTC']
u'Etc/GMT'
>>> get_global('zone_territories')['Europe/Berlin']
u'DE'
.. versionadded:: 0.9
:param key: the data key
"""
global _global_data
if _global_data is None:
dirname = os.path.join(os.path.dirname(__file__))
filename = os.path.join(dirname, 'global.dat')
if not os.path.isfile(filename):
_raise_no_data_error()
fileobj = open(filename, 'rb')
try:
_global_data = pickle.load(fileobj)
finally:
fileobj.close()
return _global_data.get(key, {})
LOCALE_ALIASES = {
'ar': 'ar_SY', 'bg': 'bg_BG', 'bs': 'bs_BA', 'ca': 'ca_ES', 'cs': 'cs_CZ',
'da': 'da_DK', 'de': 'de_DE', 'el': 'el_GR', 'en': 'en_US', 'es': 'es_ES',
'et': 'et_EE', 'fa': 'fa_IR', 'fi': 'fi_FI', 'fr': 'fr_FR', 'gl': 'gl_ES',
'he': 'he_IL', 'hu': 'hu_HU', 'id': 'id_ID', 'is': 'is_IS', 'it': 'it_IT',
'ja': 'ja_JP', 'km': 'km_KH', 'ko': 'ko_KR', 'lt': 'lt_LT', 'lv': 'lv_LV',
'mk': 'mk_MK', 'nl': 'nl_NL', 'nn': 'nn_NO', 'no': 'nb_NO', 'pl': 'pl_PL',
'pt': 'pt_PT', 'ro': 'ro_RO', 'ru': 'ru_RU', 'sk': 'sk_SK', 'sl': 'sl_SI',
'sv': 'sv_SE', 'th': 'th_TH', 'tr': 'tr_TR', 'uk': 'uk_UA'
}
class UnknownLocaleError(Exception):
"""Exception thrown when a locale is requested for which no locale data
is available.
"""
def __init__(self, identifier):
"""Create the exception.
:param identifier: the identifier string of the unsupported locale
"""
Exception.__init__(self, 'unknown locale %r' % identifier)
#: The identifier of the locale that could not be found.
self.identifier = identifier
class Locale(object):
"""Representation of a specific locale.
>>> locale = Locale('en', 'US')
>>> repr(locale)
"Locale('en', territory='US')"
>>> locale.display_name
u'English (United States)'
A `Locale` object can also be instantiated from a raw locale string:
>>> locale = Locale.parse('en-US', sep='-')
>>> repr(locale)
"Locale('en', territory='US')"
`Locale` objects provide access to a collection of locale data, such as
territory and language names, number and date format patterns, and more:
>>> locale.number_symbols['decimal']
u'.'
If a locale is requested for which no locale data is available, an
`UnknownLocaleError` is raised:
>>> Locale.parse('en_XX')
Traceback (most recent call last):
...
UnknownLocaleError: unknown locale 'en_XX'
For more information see :rfc:`3066`.
"""
def __init__(self, language, territory=None, script=None, variant=None):
"""Initialize the locale object from the given identifier components.
>>> locale = Locale('en', 'US')
>>> locale.language
'en'
>>> locale.territory
'US'
:param language: the language code
:param territory: the territory (country or region) code
:param script: the script code
:param variant: the variant code
:raise `UnknownLocaleError`: if no locale data is available for the
requested locale
"""
#: the language code
self.language = language
#: the territory (country or region) code
self.territory = territory
#: the script code
self.script = script
#: the variant code
self.variant = variant
self.__data = None
identifier = str(self)
if not localedata.exists(identifier):
raise UnknownLocaleError(identifier)
@classmethod
def default(cls, category=None, aliases=LOCALE_ALIASES):
"""Return the system default locale for the specified category.
>>> for name in ['LANGUAGE', 'LC_ALL', 'LC_CTYPE', 'LC_MESSAGES']:
... os.environ[name] = ''
>>> os.environ['LANG'] = 'fr_FR.UTF-8'
>>> Locale.default('LC_MESSAGES')
Locale('fr', territory='FR')
The following fallbacks to the variable are always considered:
- ``LANGUAGE``
- ``LC_ALL``
- ``LC_CTYPE``
- ``LANG``
:param category: one of the ``LC_XXX`` environment variable names
:param aliases: a dictionary of aliases for locale identifiers
"""
# XXX: use likely subtag expansion here instead of the
# aliases dictionary.
locale_string = default_locale(category, aliases=aliases)
return cls.parse(locale_string)
@classmethod
def negotiate(cls, preferred, available, sep='_', aliases=LOCALE_ALIASES):
"""Find the best match between available and requested locale strings.
>>> Locale.negotiate(['de_DE', 'en_US'], ['de_DE', 'de_AT'])
Locale('de', territory='DE')
>>> Locale.negotiate(['de_DE', 'en_US'], ['en', 'de'])
Locale('de')
>>> Locale.negotiate(['de_DE', 'de'], ['en_US'])
You can specify the character used in the locale identifiers to separate
the differnet components. This separator is applied to both lists. Also,
case is ignored in the comparison:
>>> Locale.negotiate(['de-DE', 'de'], ['en-us', 'de-de'], sep='-')
Locale('de', territory='DE')
:param preferred: the list of locale identifers preferred by the user
:param available: the list of locale identifiers available
:param aliases: a dictionary of aliases for locale identifiers
"""
identifier = negotiate_locale(preferred, available, sep=sep,
aliases=aliases)
if identifier:
return Locale.parse(identifier, sep=sep)
@classmethod
def parse(cls, identifier, sep='_', resolve_likely_subtags=True):
"""Create a `Locale` instance for the given locale identifier.
>>> l = Locale.parse('de-DE', sep='-')
>>> l.display_name
u'Deutsch (Deutschland)'
If the `identifier` parameter is not a string, but actually a `Locale`
object, that object is returned:
>>> Locale.parse(l)
Locale('de', territory='DE')
This also can perform resolving of likely subtags which it does
by default. This is for instance useful to figure out the most
likely locale for a territory you can use ``'und'`` as the
language tag:
>>> Locale.parse('und_AT')
Locale('de', territory='AT')
:param identifier: the locale identifier string
:param sep: optional component separator
:param resolve_likely_subtags: if this is specified then a locale will
have its likely subtag resolved if the
locale otherwise does not exist. For
instance ``zh_TW`` by itself is not a
locale that exists but Babel can
automatically expand it to the full
form of ``zh_hant_TW``. Note that this
expansion is only taking place if no
locale exists otherwise. For instance
there is a locale ``en`` that can exist
by itself.
:raise `ValueError`: if the string does not appear to be a valid locale
identifier
:raise `UnknownLocaleError`: if no locale data is available for the
requested locale
"""
if identifier is None:
return None
elif isinstance(identifier, Locale):
return identifier
elif not isinstance(identifier, string_types):
raise TypeError('Unxpected value for identifier: %r' % (identifier,))
parts = parse_locale(identifier, sep=sep)
input_id = get_locale_identifier(parts)
def _try_load(parts):
try:
return cls(*parts)
except UnknownLocaleError:
return None
def _try_load_reducing(parts):
# Success on first hit, return it.
locale = _try_load(parts)
if locale is not None:
return locale
# Now try without script and variant
locale = _try_load(parts[:2])
if locale is not None:
return locale
locale = _try_load(parts)
if locale is not None:
return locale
if not resolve_likely_subtags:
raise UnknownLocaleError(input_id)
# From here onwards is some very bad likely subtag resolving. This
# whole logic is not entirely correct but good enough (tm) for the
# time being. This has been added so that zh_TW does not cause
# errors for people when they upgrade. Later we should properly
# implement ICU like fuzzy locale objects and provide a way to
# maximize and minimize locale tags.
language, territory, script, variant = parts
language = get_global('language_aliases').get(language, language)
territory = get_global('territory_aliases').get(territory, (territory,))[0]
script = get_global('script_aliases').get(script, script)
variant = get_global('variant_aliases').get(variant, variant)
if territory == 'ZZ':
territory = None
if script == 'Zzzz':
script = None
parts = language, territory, script, variant
# First match: try the whole identifier
new_id = get_locale_identifier(parts)
likely_subtag = get_global('likely_subtags').get(new_id)
if likely_subtag is not None:
locale = _try_load_reducing(parse_locale(likely_subtag))
if locale is not None:
return locale
# If we did not find anything so far, try again with a
# simplified identifier that is just the language
likely_subtag = get_global('likely_subtags').get(language)
if likely_subtag is not None:
language2, _, script2, variant2 = parse_locale(likely_subtag)
locale = _try_load_reducing((language2, territory, script2, variant2))
if locale is not None:
return locale
raise UnknownLocaleError(input_id)
def __eq__(self, other):
for key in ('language', 'territory', 'script', 'variant'):
if not hasattr(other, key):
return False
return (self.language == other.language) and \
(self.territory == other.territory) and \
(self.script == other.script) and \
(self.variant == other.variant)
def __ne__(self, other):
return not self.__eq__(other)
def __hash__(self):
return hash((self.language, self.territory, self.script, self.variant))
def __repr__(self):
parameters = ['']
for key in ('territory', 'script', 'variant'):
value = getattr(self, key)
if value is not None:
parameters.append('%s=%r' % (key, value))
parameter_string = '%r' % self.language + ', '.join(parameters)
return 'Locale(%s)' % parameter_string
def __str__(self):
return get_locale_identifier((self.language, self.territory,
self.script, self.variant))
@property
def _data(self):
if self.__data is None:
self.__data = localedata.LocaleDataDict(localedata.load(str(self)))
return self.__data
def get_display_name(self, locale=None):
"""Return the display name of the locale using the given locale.
The display name will include the language, territory, script, and
variant, if those are specified.
>>> Locale('zh', 'CN', script='Hans').get_display_name('en')
u'Chinese (Simplified, China)'
:param locale: the locale to use
"""
if locale is None:
locale = self
locale = Locale.parse(locale)
retval = locale.languages.get(self.language)
if self.territory or self.script or self.variant:
details = []
if self.script:
details.append(locale.scripts.get(self.script))
if self.territory:
details.append(locale.territories.get(self.territory))
if self.variant:
details.append(locale.variants.get(self.variant))
details = filter(None, details)
if details:
retval += ' (%s)' % u', '.join(details)
return retval
display_name = property(get_display_name, doc="""\
The localized display name of the locale.
>>> Locale('en').display_name
u'English'
>>> Locale('en', 'US').display_name
u'English (United States)'
>>> Locale('sv').display_name
u'svenska'
:type: `unicode`
""")
def get_language_name(self, locale=None):
"""Return the language of this locale in the given locale.
>>> Locale('zh', 'CN', script='Hans').get_language_name('de')
u'Chinesisch'
.. versionadded:: 1.0
:param locale: the locale to use
"""
if locale is None:
locale = self
locale = Locale.parse(locale)
return locale.languages.get(self.language)
language_name = property(get_language_name, doc="""\
The localized language name of the locale.
>>> Locale('en', 'US').language_name
u'English'
""")
def get_territory_name(self, locale=None):
"""Return the territory name in the given locale."""
if locale is None:
locale = self
locale = Locale.parse(locale)
return locale.territories.get(self.territory)
territory_name = property(get_territory_name, doc="""\
The localized territory name of the locale if available.
>>> Locale('de', 'DE').territory_name
u'Deutschland'
""")
def get_script_name(self, locale=None):
"""Return the script name in the given locale."""
if locale is None:
locale = self
locale = Locale.parse(locale)
return locale.scripts.get(self.script)
script_name = property(get_script_name, doc="""\
The localized script name of the locale if available.
>>> Locale('sr', 'ME', script='Latn').script_name
u'latinica'
""")
@property
def english_name(self):
"""The english display name of the locale.
>>> Locale('de').english_name
u'German'
>>> Locale('de', 'DE').english_name
u'German (Germany)'
:type: `unicode`"""
return self.get_display_name(Locale('en'))
#{ General Locale Display Names
@property
def languages(self):
"""Mapping of language codes to translated language names.
>>> Locale('de', 'DE').languages['ja']
u'Japanisch'
See `ISO 639 <http://www.loc.gov/standards/iso639-2/>`_ for
more information.
"""
return self._data['languages']
@property
def scripts(self):
"""Mapping of script codes to translated script names.
>>> Locale('en', 'US').scripts['Hira']
u'Hiragana'
See `ISO 15924 <http://www.evertype.com/standards/iso15924/>`_
for more information.
"""
return self._data['scripts']
@property
def territories(self):
"""Mapping of script codes to translated script names.
>>> Locale('es', 'CO').territories['DE']
u'Alemania'
See `ISO 3166 <http://www.iso.org/iso/en/prods-services/iso3166ma/>`_
for more information.
"""
return self._data['territories']
@property
def variants(self):
"""Mapping of script codes to translated script names.
>>> Locale('de', 'DE').variants['1901']
u'Alte deutsche Rechtschreibung'
"""
return self._data['variants']
#{ Number Formatting
@property
def currencies(self):
"""Mapping of currency codes to translated currency names. This
only returns the generic form of the currency name, not the count
specific one. If an actual number is requested use the
:func:`babel.numbers.get_currency_name` function.
>>> Locale('en').currencies['COP']
u'Colombian Peso'
>>> Locale('de', 'DE').currencies['COP']
u'Kolumbianischer Peso'
"""
return self._data['currency_names']
@property
def currency_symbols(self):
"""Mapping of currency codes to symbols.
>>> Locale('en', 'US').currency_symbols['USD']
u'$'
>>> Locale('es', 'CO').currency_symbols['USD']
u'US$'
"""
return self._data['currency_symbols']
@property
def number_symbols(self):
"""Symbols used in number formatting.
>>> Locale('fr', 'FR').number_symbols['decimal']
u','
"""
return self._data['number_symbols']
@property
def decimal_formats(self):
"""Locale patterns for decimal number formatting.
>>> Locale('en', 'US').decimal_formats[None]
<NumberPattern u'#,##0.###'>
"""
return self._data['decimal_formats']
@property
def currency_formats(self):
"""Locale patterns for currency number formatting.
>>> Locale('en', 'US').currency_formats['standard']
<NumberPattern u'\\xa4#,##0.00'>
>>> Locale('en', 'US').currency_formats['accounting']
<NumberPattern u'\\xa4#,##0.00'>
"""
return self._data['currency_formats']
@property
def percent_formats(self):
"""Locale patterns for percent number formatting.
>>> Locale('en', 'US').percent_formats[None]
<NumberPattern u'#,##0%'>
"""
return self._data['percent_formats']
@property
def scientific_formats(self):
"""Locale patterns for scientific number formatting.
>>> Locale('en', 'US').scientific_formats[None]
<NumberPattern u'#E0'>
"""
return self._data['scientific_formats']
#{ Calendar Information and Date Formatting
@property
def periods(self):
"""Locale display names for day periods (AM/PM).
>>> Locale('en', 'US').periods['am']
u'AM'
"""
return self._data['periods']
@property
def days(self):
"""Locale display names for weekdays.
>>> Locale('de', 'DE').days['format']['wide'][3]
u'Donnerstag'
"""
return self._data['days']
@property
def months(self):
"""Locale display names for months.
>>> Locale('de', 'DE').months['format']['wide'][10]
u'Oktober'
"""
return self._data['months']
@property
def quarters(self):
"""Locale display names for quarters.
>>> Locale('de', 'DE').quarters['format']['wide'][1]
u'1. Quartal'
"""
return self._data['quarters']
@property
def eras(self):
"""Locale display names for eras.
>>> Locale('en', 'US').eras['wide'][1]
u'Anno Domini'
>>> Locale('en', 'US').eras['abbreviated'][0]
u'BC'
"""
return self._data['eras']
@property
def time_zones(self):
"""Locale display names for time zones.
>>> Locale('en', 'US').time_zones['Europe/London']['long']['daylight']
u'British Summer Time'
>>> Locale('en', 'US').time_zones['America/St_Johns']['city']
u'St. John\u2019s'
"""
return self._data['time_zones']
@property
def meta_zones(self):
"""Locale display names for meta time zones.
Meta time zones are basically groups of different Olson time zones that
have the same GMT offset and daylight savings time.
>>> Locale('en', 'US').meta_zones['Europe_Central']['long']['daylight']
u'Central European Summer Time'
.. versionadded:: 0.9
"""
return self._data['meta_zones']
@property
def zone_formats(self):
"""Patterns related to the formatting of time zones.
>>> Locale('en', 'US').zone_formats['fallback']
u'%(1)s (%(0)s)'
>>> Locale('pt', 'BR').zone_formats['region']
u'Hor\\xe1rio %s'
.. versionadded:: 0.9
"""
return self._data['zone_formats']
@property
def first_week_day(self):
"""The first day of a week, with 0 being Monday.
>>> Locale('de', 'DE').first_week_day
0
>>> Locale('en', 'US').first_week_day
6
"""
return self._data['week_data']['first_day']
@property
def weekend_start(self):
"""The day the weekend starts, with 0 being Monday.
>>> Locale('de', 'DE').weekend_start
5
"""
return self._data['week_data']['weekend_start']
@property
def weekend_end(self):
"""The day the weekend ends, with 0 being Monday.
>>> Locale('de', 'DE').weekend_end
6
"""
return self._data['week_data']['weekend_end']
@property
def min_week_days(self):
"""The minimum number of days in a week so that the week is counted as
the first week of a year or month.
>>> Locale('de', 'DE').min_week_days
4
"""
return self._data['week_data']['min_days']
@property
def date_formats(self):
"""Locale patterns for date formatting.
>>> Locale('en', 'US').date_formats['short']
<DateTimePattern u'M/d/yy'>
>>> Locale('fr', 'FR').date_formats['long']
<DateTimePattern u'd MMMM y'>
"""
return self._data['date_formats']
@property
def time_formats(self):
"""Locale patterns for time formatting.
>>> Locale('en', 'US').time_formats['short']
<DateTimePattern u'h:mm a'>
>>> Locale('fr', 'FR').time_formats['long']
<DateTimePattern u'HH:mm:ss z'>
"""
return self._data['time_formats']
@property
def datetime_formats(self):
"""Locale patterns for datetime formatting.
>>> Locale('en').datetime_formats['full']
u"{1} 'at' {0}"
>>> Locale('th').datetime_formats['medium']
u'{1} {0}'
"""
return self._data['datetime_formats']
@property
def plural_form(self):
"""Plural rules for the locale.
>>> Locale('en').plural_form(1)
'one'
>>> Locale('en').plural_form(0)
'other'
>>> Locale('fr').plural_form(0)
'one'
>>> Locale('ru').plural_form(100)
'many'
"""
return self._data.get('plural_form', _default_plural_rule)
@property
def list_patterns(self):
"""Patterns for generating lists
>>> Locale('en').list_patterns['start']
u'{0}, {1}'
>>> Locale('en').list_patterns['end']
u'{0}, and {1}'
>>> Locale('en_GB').list_patterns['end']
u'{0} and {1}'
"""
return self._data['list_patterns']
@property
def ordinal_form(self):
"""Plural rules for the locale.
>>> Locale('en').ordinal_form(1)
'one'
>>> Locale('en').ordinal_form(2)
'two'
>>> Locale('en').ordinal_form(3)
'few'
>>> Locale('fr').ordinal_form(2)
'other'
>>> Locale('ru').ordinal_form(100)
'other'
"""
return self._data.get('ordinal_form', _default_plural_rule)
def default_locale(category=None, aliases=LOCALE_ALIASES):
"""Returns the system default locale for a given category, based on
environment variables.
>>> for name in ['LANGUAGE', 'LC_ALL', 'LC_CTYPE']:
... os.environ[name] = ''
>>> os.environ['LANG'] = 'fr_FR.UTF-8'
>>> default_locale('LC_MESSAGES')
'fr_FR'
The "C" or "POSIX" pseudo-locales are treated as aliases for the
"en_US_POSIX" locale:
>>> os.environ['LC_MESSAGES'] = 'POSIX'
>>> default_locale('LC_MESSAGES')
'en_US_POSIX'
The following fallbacks to the variable are always considered:
- ``LANGUAGE``
- ``LC_ALL``
- ``LC_CTYPE``
- ``LANG``
:param category: one of the ``LC_XXX`` environment variable names
:param aliases: a dictionary of aliases for locale identifiers
"""
varnames = (category, 'LANGUAGE', 'LC_ALL', 'LC_CTYPE', 'LANG')
for name in filter(None, varnames):
locale = os.getenv(name)
if locale:
if name == 'LANGUAGE' and ':' in locale:
# the LANGUAGE variable may contain a colon-separated list of
# language codes; we just pick the language on the list
locale = locale.split(':')[0]
if locale.split('.')[0] in ('C', 'POSIX'):
locale = 'en_US_POSIX'
elif aliases and locale in aliases:
locale = aliases[locale]
try:
return get_locale_identifier(parse_locale(locale))
except ValueError:
pass
def negotiate_locale(preferred, available, sep='_', aliases=LOCALE_ALIASES):
"""Find the best match between available and requested locale strings.
>>> negotiate_locale(['de_DE', 'en_US'], ['de_DE', 'de_AT'])
'de_DE'
>>> negotiate_locale(['de_DE', 'en_US'], ['en', 'de'])
'de'
Case is ignored by the algorithm, the result uses the case of the preferred
locale identifier:
>>> negotiate_locale(['de_DE', 'en_US'], ['de_de', 'de_at'])
'de_DE'
>>> negotiate_locale(['de_DE', 'en_US'], ['de_de', 'de_at'])
'de_DE'
By default, some web browsers unfortunately do not include the territory
in the locale identifier for many locales, and some don't even allow the
user to easily add the territory. So while you may prefer using qualified
locale identifiers in your web-application, they would not normally match
the language-only locale sent by such browsers. To workaround that, this
function uses a default mapping of commonly used langauge-only locale
identifiers to identifiers including the territory:
>>> negotiate_locale(['ja', 'en_US'], ['ja_JP', 'en_US'])
'ja_JP'
Some browsers even use an incorrect or outdated language code, such as "no"
for Norwegian, where the correct locale identifier would actually be "nb_NO"
(Bokmål) or "nn_NO" (Nynorsk). The aliases are intended to take care of
such cases, too:
>>> negotiate_locale(['no', 'sv'], ['nb_NO', 'sv_SE'])
'nb_NO'
You can override this default mapping by passing a different `aliases`
dictionary to this function, or you can bypass the behavior althogher by
setting the `aliases` parameter to `None`.
:param preferred: the list of locale strings preferred by the user
:param available: the list of locale strings available
:param sep: character that separates the different parts of the locale
strings
:param aliases: a dictionary of aliases for locale identifiers
"""
available = [a.lower() for a in available if a]
for locale in preferred:
ll = locale.lower()
if ll in available:
return locale
if aliases:
alias = aliases.get(ll)
if alias:
alias = alias.replace('_', sep)
if alias.lower() in available:
return alias
parts = locale.split(sep)
if len(parts) > 1 and parts[0].lower() in available:
return parts[0]
return None
def parse_locale(identifier, sep='_'):
"""Parse a locale identifier into a tuple of the form ``(language,
territory, script, variant)``.
>>> parse_locale('zh_CN')
('zh', 'CN', None, None)
>>> parse_locale('zh_Hans_CN')
('zh', 'CN', 'Hans', None)
The default component separator is "_", but a different separator can be
specified using the `sep` parameter:
>>> parse_locale('zh-CN', sep='-')
('zh', 'CN', None, None)
If the identifier cannot be parsed into a locale, a `ValueError` exception
is raised:
>>> parse_locale('not_a_LOCALE_String')
Traceback (most recent call last):
...
ValueError: 'not_a_LOCALE_String' is not a valid locale identifier
Encoding information and locale modifiers are removed from the identifier:
>>> parse_locale('it_IT@euro')
('it', 'IT', None, None)
>>> parse_locale('en_US.UTF-8')
('en', 'US', None, None)
>>> parse_locale('de_DE.iso885915@euro')
('de', 'DE', None, None)
See :rfc:`4646` for more information.
:param identifier: the locale identifier string
:param sep: character that separates the different components of the locale
identifier
:raise `ValueError`: if the string does not appear to be a valid locale
identifier
"""
if '.' in identifier:
# this is probably the charset/encoding, which we don't care about
identifier = identifier.split('.', 1)[0]
if '@' in identifier:
# this is a locale modifier such as @euro, which we don't care about
# either
identifier = identifier.split('@', 1)[0]
parts = identifier.split(sep)
lang = parts.pop(0).lower()
if not lang.isalpha():
raise ValueError('expected only letters, got %r' % lang)
script = territory = variant = None
if parts:
if len(parts[0]) == 4 and parts[0].isalpha():
script = parts.pop(0).title()
if parts:
if len(parts[0]) == 2 and parts[0].isalpha():
territory = parts.pop(0).upper()
elif len(parts[0]) == 3 and parts[0].isdigit():
territory = parts.pop(0)
if parts:
if len(parts[0]) == 4 and parts[0][0].isdigit() or \
len(parts[0]) >= 5 and parts[0][0].isalpha():
variant = parts.pop()
if parts:
raise ValueError('%r is not a valid locale identifier' % identifier)
return lang, territory, script, variant
def get_locale_identifier(tup, sep='_'):
"""The reverse of :func:`parse_locale`. It creates a locale identifier out
of a ``(language, territory, script, variant)`` tuple. Items can be set to
``None`` and trailing ``None``\s can also be left out of the tuple.
>>> get_locale_identifier(('de', 'DE', None, '1999'))
'de_DE_1999'
.. versionadded:: 1.0
:param tup: the tuple as returned by :func:`parse_locale`.
:param sep: the separator for the identifier.
"""
tup = tuple(tup[:4])
lang, territory, script, variant = tup + (None,) * (4 - len(tup))
return sep.join(filter(None, (lang, script, territory, variant)))
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,48 @@
# -*- coding: utf-8 -*-
"""
babel.lists
~~~~~~~~~~~
Locale dependent formatting of lists.
The default locale for the functions in this module is determined by the
following environment variables, in that order:
* ``LC_ALL``, and
* ``LANG``
:copyright: (c) 2015 by the Babel Team.
:license: BSD, see LICENSE for more details.
"""
from babel.core import Locale, default_locale
DEFAULT_LOCALE = default_locale()
def format_list(lst, locale=DEFAULT_LOCALE):
""" Formats `lst` as a list
e.g.
>>> format_list(['apples', 'oranges', 'pears'], 'en')
u'apples, oranges, and pears'
>>> format_list(['apples', 'oranges', 'pears'], 'zh')
u'apples\u3001oranges\u548cpears'
:param lst: a sequence of items to format in to a list
:param locale: the locale
"""
locale = Locale.parse(locale)
if not lst:
return ''
if len(lst) == 1:
return lst[0]
if len(lst) == 2:
return locale.list_patterns['2'].format(*lst)
result = locale.list_patterns['start'].format(lst[0], lst[1])
for elem in lst[2:-1]:
result = locale.list_patterns['middle'].format(result, elem)
result = locale.list_patterns['end'].format(result, lst[-1])
return result
Loaded 100 of 1889 files, more files were not shown because too many files have changed in this diff. Show more