Create package

This commit is contained in:
trueold89 2024-03-25 07:14:53 +03:00
parent 10447aa6bd
commit 41422cce40
Signed by: trueold89
GPG Key ID: C122E85DD49E6B30
5 changed files with 25 additions and 3 deletions

4
.gitignore vendored
View File

@ -1,4 +1,6 @@
old/ old/
probe.py VoidServiceControl/main.py
__pycache__ __pycache__
.idea .idea
.venv
probe.py

View File

@ -1,4 +1,5 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
import importlib.resources
import json import json
from enum import Enum from enum import Enum
from os import listdir as ls from os import listdir as ls
@ -6,6 +7,7 @@ from subprocess import run as execute
from subprocess import PIPE from subprocess import PIPE
from sys import argv from sys import argv
from VoidServiceControl.env import * from VoidServiceControl.env import *
@ -164,10 +166,10 @@ class Translate(object):
@property @property
def __translation(self): def __translation(self):
try: try:
with open(f"VoidServiceControl/languages/{self.lang}.json", "r", encoding="utf-8") as json_file: with importlib.resources.open_text(__package__, f"{self.lang}.json", "utf-8") as json_file:
return json.loads(json_file.read()) return json.loads(json_file.read())
except FileNotFoundError: except FileNotFoundError:
with open(f"VoidServiceControl/languages/en_US.json", "r", encoding="utf-8") as json_file: with importlib.resources.open_text(__package__, f"en_US.json", "utf-8") as json_file:
return json.loads(json_file.read()) return json.loads(json_file.read())

18
setup.py Normal file
View File

@ -0,0 +1,18 @@
from setuptools import setup
setup(
name='VoidServiceControl',
version='0.2',
url='https://git.orudo.ru/trueold89/void-service-control',
author='trueold89',
author_email='trueold89@orudo.ru',
description="A simple script that will allow you to manage runit services in Void Linux",
packages=['VoidServiceControl'],
long_description=open('README.md').read(),
entry_points={
"console_scripts": ["vsc = VoidServiceControl.main:main"]
},
package_data={
'VoidServiceControl': ['*.json'],
},
)