Skip to content

Commit b5b68a5

Browse files
Merge pull request #12 from leandrodamascena/developer
New release
2 parents f2d6a2f + 3d5ac65 commit b5b68a5

File tree

14 files changed

+307
-13
lines changed

14 files changed

+307
-13
lines changed

.gitignore

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,6 @@ coverage.xml
5656
.hypothesis/
5757
.pytest_cache/
5858

59-
# Translations
60-
*.mo
61-
*.pot
62-
6359
# Scrapy stuff:
6460
.scrapy
6561

README.md

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ Following services are integrated
1414
- RDS
1515
- EFS
1616
- ELASTICACHE
17+
- S3 POLICY
18+
- ELASTICSEARCH
19+
- DOCUMENTDB
20+
- SQS QUEUE POLICY
1721

1822
### Requirements and Installation
1923

@@ -51,7 +55,21 @@ $ ./aws-network-discovery.py --vpc-id vpc-xxxxxxx --region-name xx-xxxx-xxx
5155
```sh
5256
$ ./aws-network-discovery.py -h
5357
```
54-
### Todo
58+
59+
### Translate
60+
61+
This project support English and Portuguese (Brazil) languages. To contribute with a translation, follow this steps:
62+
63+
- Create a folder inside locales folder with prefix of new idiom with appropiate locale code (https://docs.oracle.com/cd/E23824_01/html/E26033/glset.html). Copy "locales/messages.pot" to locales/newfolder/LC_MESSAGES/.
64+
65+
- To build ".mo" file running this command from project root folder:
66+
67+
```sh
68+
$ python msgfmt.py -o locales/NEWFOLDER/LC_MESSAGES/messages.mo locales/NEWFOLDER/LC_MESSAGES/messages
69+
```
70+
71+
72+
### TODO
5573

5674
- Use role instance rather than aws-cli
5775
- Improve documentation and code comments

aws-network-discovery.py

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,19 @@
2626
"""
2727
import sys
2828
import argparse
29+
import gettext
2930

3031
# Check version
3132
if sys.version_info < (3, 6):
32-
print("Python 3.6 or newer is required", file=sys.stderr)
33+
print(_("Python 3.6 or newer is required"), file=sys.stderr)
3334
sys.exit(1)
3435

3536

3637
from commands.vpc import Vpc
3738

38-
__version__ = "0.3.0"
39+
__version__ = "0.4.0"
40+
41+
AVAILABLE_LANGUAGES = ['en_US','pt_BR']
3942

4043
def show_options(args="sys.argv[1:]"):
4144
parser = argparse.ArgumentParser()
@@ -57,6 +60,12 @@ def show_options(args="sys.argv[1:]"):
5760
required=False,
5861
help="Profile to be used"
5962
)
63+
parser.add_argument(
64+
"-l",
65+
"--language",
66+
required=False,
67+
help="available languages: pt_BR, en_US"
68+
)
6069
args = parser.parse_args()
6170

6271
return args
@@ -71,6 +80,18 @@ def main():
7180

7281
args = show_options(sys.argv)
7382

83+
if args.language is None or args.language not in AVAILABLE_LANGUAGES:
84+
language = "en_US"
85+
else:
86+
language = args.language
87+
88+
89+
""" defining default language to show messages """
90+
defaultlanguage = gettext.translation('messages', localedir='locales', languages=[language])
91+
defaultlanguage.install()
92+
_ = defaultlanguage.gettext
93+
94+
7495
vpc = Vpc(vpc_id=args.vpc_id, region_name=args.region_name, profile_name=args.profile_name)
7596
vpc.run()
7697

commands/vpc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def run(self):
1717
region_name = session.region_name
1818

1919
if self.region_name is None and region_name is None:
20-
exit_critical("Neither region parameter or region config were informed")
20+
exit_critical(_("Neither region parameter or region config were informed"))
2121

2222
""" assuming region parameter precedes region configuration """
2323
if self.region_name is not None:
383 Bytes
Binary file not shown.
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# SOME DESCRIPTIVE TITLE.
2+
# Copyright (C) YEAR ORGANIZATION
3+
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
4+
#
5+
msgid ""
6+
msgstr ""
7+
"Project-Id-Version: PACKAGE VERSION\n"
8+
"POT-Creation-Date: 2020-05-04 16:43+0100\n"
9+
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
10+
"Last-Translator: Leandro Damascena <leandro.damascena at gmail.com>\n"
11+
"Language-Team: en_US <[email protected]>\n"
12+
"MIME-Version: 1.0\n"
13+
"Content-Type: text/plain; charset=cp1252\n"
14+
"Content-Transfer-Encoding: 8bit\n"
15+
"Generated-By: pygettext.py 1.5\n"
16+
17+
#: .\aws-network-discovery.py:33
18+
msgid "Python 3.6 or newer is required"
19+
msgstr ""
20+
21+
#: .\commands\vpc.py:20
22+
msgid "Neither region parameter or region config were informed"
23+
msgstr ""

locales/messages.pot

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# SOME DESCRIPTIVE TITLE.
2+
# Copyright (C) YEAR ORGANIZATION
3+
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
4+
#
5+
msgid ""
6+
msgstr ""
7+
"Project-Id-Version: PACKAGE VERSION\n"
8+
"POT-Creation-Date: 2020-05-04 20:25+0100\n"
9+
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
10+
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
11+
"Language-Team: LANGUAGE <[email protected]>\n"
12+
"MIME-Version: 1.0\n"
13+
"Content-Type: text/plain; charset=cp1252\n"
14+
"Content-Transfer-Encoding: 8bit\n"
15+
"Generated-By: pygettext.py 1.5\n"
16+
17+
#: .\aws-network-discovery.py:33
18+
msgid "Python 3.6 or newer is required"
19+
msgstr ""
20+
21+
#: .\commands\vpc.py:20
22+
msgid "Neither region parameter or region config were informed"
23+
msgstr ""
631 Bytes
Binary file not shown.
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# SOME DESCRIPTIVE TITLE.
2+
# Copyright (C) YEAR ORGANIZATION
3+
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
4+
#
5+
msgid ""
6+
msgstr ""
7+
"Project-Id-Version: PACKAGE VERSION\n"
8+
"POT-Creation-Date: 2020-05-04 16:43+0100\n"
9+
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
10+
"Last-Translator: Leandro Damascena <leandro.damascena at gmail.com>\n"
11+
"Language-Team: en_US <[email protected]>\n"
12+
"MIME-Version: 1.0\n"
13+
"Content-Type: text/plain; charset=UTF-8\n"
14+
"Content-Transfer-Encoding: 8bit\n"
15+
"Generated-By: pygettext.py 1.5\n"
16+
17+
#: .\aws-network-discovery.py:33
18+
msgid "Python 3.6 or newer is required"
19+
msgstr "É necessário ter o Python 3.6 ou superior instalado"
20+
21+
#: .\commands\vpc.py:20
22+
msgid "Neither region parameter or region config were informed"
23+
msgstr "É preciso informar uma região ou configurar o profile com uma região"

shared/awscommands.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@
22
from shared.internal.security import IAM, IAMPOLICY
33
from shared.internal.network import VPC
44
from shared.internal.compute import LAMBDA, EC2
5-
from shared.internal.database import RDS, ELASTICACHE
6-
from shared.internal.storage import EFS
5+
from shared.internal.database import RDS, ELASTICACHE, DOCUMENTDB
6+
from shared.internal.storage import EFS, S3POLICY
7+
from shared.internal.analytics import ELASTICSEARCH
8+
from shared.internal.application import SQSPOLICY
79

810

911
class AwsCommands(object):
@@ -20,3 +22,7 @@ def run(self):
2022
EFS(self.vpc_options).run()
2123
ELASTICACHE(self.vpc_options).run()
2224
IAMPOLICY(self.vpc_options).run()
25+
S3POLICY(self.vpc_options).run()
26+
ELASTICSEARCH(self.vpc_options).run()
27+
DOCUMENTDB(self.vpc_options).run()
28+
SQSPOLICY(self.vpc_options).run()

0 commit comments

Comments
 (0)