Skip to content
This repository has been archived by the owner on Dec 2, 2024. It is now read-only.

Commit

Permalink
Merge pull request #7 from opengisch/pytransifex-api_v3
Browse files Browse the repository at this point in the history
Pytransifex api v3
  • Loading branch information
3nids authored Feb 16, 2023
2 parents 473d44d + 8b8046b commit 2148ecf
Show file tree
Hide file tree
Showing 27 changed files with 1,192 additions and 539 deletions.
2 changes: 2 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
TX_TOKEN=0123456789
ORGANIZATION=test_pytransifex
16 changes: 16 additions & 0 deletions .github/workflows/pre-commit.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: pre-commit

on:
pull_request:
branches:
- master
push:
branches:
- master

jobs:
pre-commit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: pre-commit/[email protected]
29 changes: 29 additions & 0 deletions .github/workflows/test_pytx.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: test pytransifex

on:
pull_request:
branches:
- master
push:
branches:
- master

jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Check out repository code
uses: actions/checkout@v3

- uses: actions/setup-python@v4
with:
python-version: "3.10"

- name: Run CI tests
env:
organization: ${{ secrets.ORGANIZATION }}
tx_token: ${{ secrets.TX_TOKEN }}
run: |
pip install -r requirements.txt
TX_TOKEN=$tx_token ORGANIZATION=$organization \
python -m unittest discover -s ./tests -p 'test_*.py'
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,8 @@ __pycache__/
venv/

.idea
.DS_Store
.DS_Store
.vscode/settings.json
Pipfile
Pipfile.lock
.env
36 changes: 36 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
repos:
# Fix end of files
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.2.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: mixed-line-ending
args:
- '--fix=lf'

# Remove unused imports/variables
- repo: https://github.com/myint/autoflake
rev: v1.4
hooks:
- id: autoflake
args:
- "--in-place"
- "--remove-all-unused-imports"
- "--remove-unused-variable"
- "--ignore-init-module-imports"

# Sort imports
- repo: https://github.com/pycqa/isort
rev: "5.12.0"
hooks:
- id: isort
args:
- --profile
- black

# Black formatting
- repo: https://github.com/psf/black
rev: 22.3.0
hooks:
- id: black
2 changes: 0 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,3 @@ deploy:
on:
branch: master
tags: true


28 changes: 28 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,31 @@
Read the documentation: https://opengisch.github.io/pytransifex

This was largely based on https://github.com/jakul/python-transifex which was not made available for Python 3.

This can be imported as a library or run as a CLI executable (`pytx`). Read on for the latter use case.

### Build the package (required for consuming the package as a CLI)

Ensure that `build` is installed for the current user or project:
- current user: `pip3 --user install build`
- local project: `pipenv install --dev build`

#### 1. Build the installable archive

Build the package:
- current user: `pip3 -m build`
- local project: `pipenv run build`

#### 2. Install from the archive

This will create a `dist` in the current directory, with a `tar.gz` archive in it. You can finally install it:
- current user: `pip3 --user install <path/to/the/archive>`
- local project: `pipenv install <path/to/the/archive>`

#### 3. Run the pytx cli

Once installed the package can be run as a CLI; example:

pytx pull name -l fr

Run `pytx --help` for more information.
2 changes: 1 addition & 1 deletion docs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ help:
# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
2 changes: 1 addition & 1 deletion docs/build_deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ echo "building docs"
pushd docs
sed -i "s/__VERSION__/${TRAVIS_TAG}/" conf.py
make html
popd
popd
74 changes: 40 additions & 34 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,27 +14,28 @@
#
import os
import sys
sys.path.insert(0, os.path.abspath('..'))

sys.path.insert(0, os.path.abspath(".."))


# -- Project information -----------------------------------------------------

project = 'pytransifex'
copyright = '2019, Denis Rouzaud'
author = 'Denis Rouzaud'
project = "pytransifex"
copyright = "2019, Denis Rouzaud"
author = "Denis Rouzaud"

# The short X.Y version
version = '__VERSION__'
version = "__VERSION__"
# The full version, including alpha/beta/rc tags
release = '__VERSION__'
release = "__VERSION__"


# -- General configuration ---------------------------------------------------

autoclass_content = "class"
autodoc_default_flags = [
"members",
"show-inheritance",
"members",
"show-inheritance",
]
autosummary_generate = True # Make _autosummary files and include them
napoleon_numpy_docstring = True # Force consistency, leave only Google
Expand All @@ -44,25 +45,25 @@
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
'sphinx.ext.autodoc',
'sphinx.ext.coverage',
'sphinx.ext.viewcode',
'sphinx.ext.githubpages',
'sphinx.ext.napoleon',
'sphinx.ext.autosummary'
"sphinx.ext.autodoc",
"sphinx.ext.coverage",
"sphinx.ext.viewcode",
"sphinx.ext.githubpages",
"sphinx.ext.napoleon",
"sphinx.ext.autosummary",
]

# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
templates_path = ["_templates"]

# The suffix(es) of source filenames.
# You can specify multiple suffix as a list of string:
#
# source_suffix = ['.rst', '.md']
source_suffix = '.rst'
source_suffix = ".rst"

# The master toctree document.
master_doc = 'index'
master_doc = "index"

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand All @@ -74,7 +75,7 @@
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This pattern also affects html_static_path and html_extra_path.
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]

# The name of the Pygments (syntax highlighting) style to use.
pygments_style = None
Expand All @@ -85,7 +86,7 @@
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
html_theme = 'sphinx_rtd_theme'
html_theme = "sphinx_rtd_theme"

# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
Expand All @@ -96,7 +97,7 @@
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']
html_static_path = ["_static"]

# Custom sidebar templates, must be a dictionary that maps document names
# to template names.
Expand All @@ -112,7 +113,7 @@
# -- Options for HTMLHelp output ---------------------------------------------

# Output file base name for HTML help builder.
htmlhelp_basename = 'pytransifexdoc'
htmlhelp_basename = "pytransifexdoc"


# -- Options for LaTeX output ------------------------------------------------
Expand All @@ -121,15 +122,12 @@
# The paper size ('letterpaper' or 'a4paper').
#
# 'papersize': 'letterpaper',

# The font size ('10pt', '11pt' or '12pt').
#
# 'pointsize': '10pt',

# Additional stuff for the LaTeX preamble.
#
# 'preamble': '',

# Latex figure (float) alignment
#
# 'figure_align': 'htbp',
Expand All @@ -139,19 +137,21 @@
# (source start file, target name, title,
# author, documentclass [howto, manual, or own class]).
latex_documents = [
(master_doc, 'pytransifex.tex', 'pytransifex Documentation',
'Denis Rouzaud', 'manual'),
(
master_doc,
"pytransifex.tex",
"pytransifex Documentation",
"Denis Rouzaud",
"manual",
),
]


# -- Options for manual page output ------------------------------------------

# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
(master_doc, 'pytransifex', 'pytransifex Documentation',
[author], 1)
]
man_pages = [(master_doc, "pytransifex", "pytransifex Documentation", [author], 1)]


# -- Options for Texinfo output ----------------------------------------------
Expand All @@ -160,9 +160,15 @@
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
(master_doc, 'pytransifex', 'pytransifex Documentation',
author, 'pytransifex', 'One line description of project.',
'Miscellaneous'),
(
master_doc,
"pytransifex",
"pytransifex Documentation",
author,
"pytransifex",
"One line description of project.",
"Miscellaneous",
),
]


Expand All @@ -181,7 +187,7 @@
# epub_uid = ''

# A list of files that should not be packed into the epub file.
epub_exclude_files = ['search.html']
epub_exclude_files = ["search.html"]


# -- Extension configuration -------------------------------------------------
6 changes: 2 additions & 4 deletions pytransifex/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import logging



from pytransifex.api import Transifex
from pytransifex.exceptions import TransifexException, PyTransifexException, InvalidSlugException
logging.basicConfig(level=logging.INFO)
4 changes: 4 additions & 0 deletions pytransifex/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from pytransifex.cli import cli

if __name__ == "__main__":
cli()
Loading

0 comments on commit 2148ecf

Please sign in to comment.