Skip to content

Commit

Permalink
Add configuration for python package
Browse files Browse the repository at this point in the history
  • Loading branch information
Roman Gille committed Jan 21, 2021
1 parent 2f3e652 commit e309227
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 13 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
.DS_Store
/.vscode
*.egg-info
/dist
/build
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ This is a python script that downloads localization strings and CI color informa

![Vizualization of the workflow](Resources/workflow.jpg)

## Installation

pip install localization-sync

## Prerequisites

Create a Google Sheet document with sheets like [these](https://docs.google.com/spreadsheets/d/1672QPWDsxBtaX5hc5QgZhqBwLADMnPVEv7-wLB3g-ug):
Expand All @@ -20,7 +24,9 @@ Find the ID of your document by copying it from your browsers address bar.

Create a `data_sync.config.json` in your project and populate it with the contents of the [example config](data_sync.config.json). Replace the `sheetId` with your own. You can modify the other settings to fit the needs of your project.

Then open a terminal at your project path and run `python3 Sources/data_sync.py`. Look for your newly created resource files.
Then open a terminal at your project path and run `l10n_sync`. Look for your newly created resource files.

You can also copy [data_sync.py](Sources/data_sync.py) to your project and then run `python3 data_sync.py` when your config file is ready.

## Example

Expand Down
1 change: 1 addition & 0 deletions Sources/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#!/usr/bin/python
29 changes: 17 additions & 12 deletions Sources/data_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,15 +243,20 @@ def run(config):
tableData = parseDocument(sheetId, colorConfig["sheetNumber"])
writeColors(tableData, colorConfig)

# Parse config file and run tasks.
try:
with open(configFileName, 'r') as stream:
config = json.load(stream)
run(config)

except json.JSONDecodeError as exc:
print("Error parsing config file: ")
print(exc)

except FileNotFoundError:
print("Error: Could not find \"" + configFileName + "\". This should be placed at the run directory of this script. Current run directory is \"" + scriptRunPath +"\".")
def main():
# Parse config file and run tasks.
try:
with open(configFileName, 'r') as stream:
config = json.load(stream)
run(config)

except json.JSONDecodeError as exc:
print("Error parsing config file: ")
print(exc)

except FileNotFoundError:
print("Error: Could not find \"" + configFileName + "\". This should be placed at the run directory of this script. Current run directory is \"" + scriptRunPath +"\".")

# This will get called when the file is called via `python fileneme.py`
if __name__ == '__main__':
main()
32 changes: 32 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import setuptools

with open("README.md", "r", encoding="utf-8") as fh:
long_description = fh.read()

setuptools.setup(
name="localization-sync",
entry_points= {
'console_scripts': [
'l10n_sync = Sources.data_sync:main',
],
},
version="0.1.0",
author="Roman Gille",
author_email="[email protected]",
description="A python script that generates localization files for iOS and Android projects from a public GoogleSheet.",
long_description=long_description,
long_description_content_type="text/markdown",
url="https://github.com/r-dent/LocalizationSync",
packages=setuptools.find_packages(),
classifiers=[
"Programming Language :: Python :: 3",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
"Intended Audience :: Developers",
"Topic :: Software Development :: Code Generators",
"Topic :: Software Development :: Localization",
"Topic :: Software Development :: Embedded Systems",
"Topic :: Utilities",
],
python_requires='>=3.6',
)

0 comments on commit e309227

Please sign in to comment.