From 652f2e17636c080d4e9c9d8ade2ff645d9f6067b Mon Sep 17 00:00:00 2001 From: Oleg Broytman Date: Sun, 16 Apr 2017 14:58:41 +0300 Subject: [PATCH 1/1] Split defenc.py from m_lib into a separate namespace package --- .gitignore | 1 + MANIFEST.in | 2 ++ Makefile | 8 ++++++++ README.txt | 7 +++++++ m_lib/__init__.py | 5 +++++ m_lib/defenc.py | 37 +++++++++++++++++++++++++++++++++++++ mk-distr | 10 ++++++++++ requirements.txt | 3 +++ setup.cfg | 9 +++++++++ setup.py | 35 +++++++++++++++++++++++++++++++++++ update | 2 ++ 11 files changed, 119 insertions(+) create mode 100644 .gitignore create mode 100644 MANIFEST.in create mode 100644 Makefile create mode 100644 README.txt create mode 100644 m_lib/__init__.py create mode 100755 m_lib/defenc.py create mode 100755 mk-distr create mode 100644 requirements.txt create mode 100644 setup.cfg create mode 100755 setup.py create mode 100755 update diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..539da74 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +*.py[co] diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 0000000..858f5e2 --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1,2 @@ +global-include *.py *.txt +include MANIFEST.in Makefile mk-distr diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..89ab254 --- /dev/null +++ b/Makefile @@ -0,0 +1,8 @@ + +.PHONY: distr +distr: + ./mk-distr + +.PHONY: clean +clean: + find . -name '*.py[co]' -type f -delete diff --git a/README.txt b/README.txt new file mode 100644 index 0000000..887eefb --- /dev/null +++ b/README.txt @@ -0,0 +1,7 @@ +Broytman Library for Python, Copyright (C) 1996-2017 PhiloSoft Design +Author: Oleg Broytman +License: GPL + +Content of the namespace pakage: + +defenc.py - get default encoding. diff --git a/m_lib/__init__.py b/m_lib/__init__.py new file mode 100644 index 0000000..bdbd21e --- /dev/null +++ b/m_lib/__init__.py @@ -0,0 +1,5 @@ +"""Broytman Library for Python, Copyright (C) 1996-2017 PhiloSoft Design""" + +from pkgutil import extend_path +__path__ = extend_path(__path__, __name__) +__import__('pkg_resources').declare_namespace(__name__) diff --git a/m_lib/defenc.py b/m_lib/defenc.py new file mode 100755 index 0000000..776b78d --- /dev/null +++ b/m_lib/defenc.py @@ -0,0 +1,37 @@ +#! /usr/bin/env python +"""Get default encoding""" + +from __future__ import print_function +import sys + +try: + import locale + use_locale = True +except ImportError: + use_locale = False + +__all__ = ['default_encoding'] + +if use_locale: + # Get the default charset. + try: + lcAll = locale.getdefaultlocale() + except locale.Error as err: + print("WARNING:", err, file=sys.stderr) + lcAll = [] + + if len(lcAll) == 2 and lcAll[0] is not None: + default_encoding = lcAll[1] + else: + try: + default_encoding = locale.getpreferredencoding() + except locale.Error as err: + print("WARNING:", err, file=sys.stderr) + default_encoding = sys.getdefaultencoding() +else: + default_encoding = sys.getdefaultencoding() + +default_encoding = default_encoding.lower() + +if __name__ == "__main__": + print(default_encoding) diff --git a/mk-distr b/mk-distr new file mode 100755 index 0000000..011aeeb --- /dev/null +++ b/mk-distr @@ -0,0 +1,10 @@ +#! /bin/sh + +umask 022 && + +git archive --format=tar --prefix=m_lib.defenc/ "${1:-HEAD}" | + (cd "$HOME/tmp" && exec tar xf -) && + +cd "$HOME/tmp/m_lib.defenc" && +python setup.py sdist --formats=bztar && +cd dist && mv m_lib.defenc-*.tar.bz2 ../.. && cd ../.. && exec rm -rf m_lib.defenc diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..a93f011 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,3 @@ +--trusted-host phdru.name +--find-links=http://phdru.name/Software/Python/ +--install-option=-O2 diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 0000000..56a3566 --- /dev/null +++ b/setup.cfg @@ -0,0 +1,9 @@ +[easy_install] +find_links = http://phdru.name/Software/Python/ +optimize = 2 + +[egg_info] +tag_build = +tag_date = 0 +tag_svn_revision = 0 + diff --git a/setup.py b/setup.py new file mode 100755 index 0000000..e15eacb --- /dev/null +++ b/setup.py @@ -0,0 +1,35 @@ +#! /usr/bin/env python + +try: + from setuptools import setup + is_setuptools = True +except ImportError: + from distutils.core import setup + is_setuptools = False + +setup(name = "m_lib.defenc", + version = "1.0.0", + description = "Broytman Library for Python", + long_description = "Broytman Library for Python, Copyright (C) 1996-2017 PhiloSoft Design", + author = "Oleg Broytman", + author_email = "phd@phdru.name", + url = "http://phdru.name/Software/Python/#m_lib", + license = "GPL", + keywords=[''], + classifiers=[ + 'Development Status :: 5 - Production/Stable', + 'Intended Audience :: Developers', + 'License :: OSI Approved :: GNU General Public License (GPL)', + 'Operating System :: OS Independent', + 'Programming Language :: Python :: 2', + 'Programming Language :: Python :: 2.6', + 'Programming Language :: Python :: 2.7', + 'Programming Language :: Python :: 3', + 'Programming Language :: Python :: 3.4', + 'Topic :: Software Development :: Libraries', + 'Topic :: Software Development :: Libraries :: Python Modules', + ], + platforms = "All", + packages = ["m_lib"], + namespace_packages = ["m_lib"], +) diff --git a/update b/update new file mode 100755 index 0000000..690ecaa --- /dev/null +++ b/update @@ -0,0 +1,2 @@ +#! /bin/sh +exec "$HOME"/admin/prog/git-scripts/update -- 2.39.5