Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,6 @@ jobs:
${{ matrix.os }}-${{ matrix.python-version }}-v1-
- name: Install dependencies
run: |
sudo apt-get install gettext
python -m pip install -U pip
python -m pip install -e .
182 changes: 0 additions & 182 deletions formalchemy/msgfmt.py

This file was deleted.

41 changes: 18 additions & 23 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,35 +4,16 @@
from os.path import join
import sys
import os
import glob
import pathlib
import subprocess

def get_version(fname='formalchemy/__init__.py'):
with open(fname) as f:
for line in f:
if line.startswith('__version__'):
return eval(line.split('=')[-1])

try:
from msgfmt import Msgfmt
except:
sys.path.insert(0, join(os.getcwd(), 'formalchemy'))

def compile_po(path):
from msgfmt import Msgfmt
for language in os.listdir(path):
lc_path = join(path, language, 'LC_MESSAGES')
if os.path.isdir(lc_path):
for domain_file in os.listdir(lc_path):
if domain_file.endswith('.po'):
file_path = join(lc_path, domain_file)
mo_file = join(lc_path, '%s.mo' % domain_file[:-3])
mo_content = Msgfmt(file_path, name=file_path).get()
mo = open(mo_file, 'wb')
mo.write(mo_content)
mo.close()

# We compile .mo files during setup. Don't think, it is a good idea. [sallner]
compile_po(join(os.getcwd(), 'formalchemy', 'i18n_resources'))

def read(filename):
text = open(filename,'r').read()
return xml.sax.saxutils.escape(text)
Expand All @@ -44,6 +25,20 @@ def read(filename):
'\n\n' +\
read('CHANGELOG.rst')

PO_FILES = 'i18n_resources/*/LC_MESSAGES/formalchemy.po'

def create_mo_files():
mo_files = []
prefix = 'formalchemy'

for po_path in glob.glob(str(pathlib.Path(prefix) / PO_FILES)):
mo = pathlib.Path(po_path.replace('.po', '.mo'))

subprocess.run(['msgfmt', '-o', str(mo), po_path], check=True)
mo_files.append(str(mo.relative_to(prefix)))

return mo_files

setup(name='FormAlchemy',
license='MIT License',
version=get_version(),
Expand All @@ -58,7 +53,7 @@ def read(filename):
'ext/pylons/*.mako', 'ext/pylons/resources/*.css', 'ext/pylons/resources/*.png',
'tests/data/mako/*.mako', 'tests/data/genshi/*.html',
'paster_templates/pylons_fa/+package+/*/*_tmpl',
]},
] + create_mo_files()},
include_package_data=True,
classifiers=[
'Development Status :: 5 - Production/Stable',
Expand Down