-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor files & add automated protobuf aggregation
- Loading branch information
1 parent
27b18b4
commit b6fca64
Showing
242 changed files
with
293 additions
and
17,166 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
.idea | ||
*.pyc | ||
*.py | ||
*.pyi | ||
test/ | ||
dist/ | ||
cosmospy_protobuf.egg-info | ||
cosmospy_protobuf.egg-info | ||
tmp/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
import errno | ||
import json | ||
import os | ||
import shutil | ||
import time | ||
from os.path import dirname, abspath, isfile | ||
import argparse | ||
|
||
from git import Repo | ||
|
||
parser = argparse.ArgumentParser(description='Aggregate all protobuf files') | ||
parser.add_argument('coin', type=str, help="Coin to parse from the .json file in the config folder") | ||
args = parser.parse_args() | ||
|
||
# Get current directory | ||
d = dirname(abspath(__file__)) | ||
|
||
# Check if requested coin has a config | ||
coin = args.coin | ||
try: | ||
config_path = os.path.join(d, f'configs/{coin.lower()}.json') | ||
f = open(config_path, "r") | ||
coin_config = json.load(f) | ||
f.close() | ||
except Exception: | ||
print("Coin couldn't be found") | ||
exit() | ||
|
||
|
||
tmp_dir = os.path.join(d, "tmp") | ||
if not os.path.isdir(tmp_dir): | ||
os.mkdir(tmp_dir) | ||
|
||
project_dir = os.path.join(tmp_dir, str(time.time())) | ||
os.mkdir(project_dir) | ||
|
||
# Delete all existing protobuf files | ||
root_dir = 'src/cosmospy_protobuf' | ||
root_abs_path = os.path.join(d, root_dir) | ||
for filename in os.listdir(root_abs_path): | ||
file_path = os.path.join(root_abs_path, filename) | ||
try: | ||
if os.path.isfile(file_path) or os.path.islink(file_path): | ||
os.unlink(file_path) | ||
elif os.path.isdir(file_path): | ||
shutil.rmtree(file_path) | ||
except Exception as e: | ||
print('Failed to delete %s. Reason: %s' % (file_path, e)) | ||
|
||
# Load config | ||
i = 1 | ||
for repo_url, repo_config in coin_config.items(): | ||
print(f"Cloning {repo_url} | {repo_config['branch']}") | ||
repo_dir = project_dir + "/" + str(i) | ||
Repo.clone_from( | ||
repo_url, | ||
project_dir + "/" + str(i), | ||
branch=repo_config['branch'] | ||
) | ||
|
||
# Copy proto files to root_dir | ||
for proto_folder in repo_config['paths']: | ||
proto_dir = os.path.join(repo_dir, proto_folder) | ||
category_name = proto_folder.split('/')[-1] | ||
try: | ||
shutil.copytree(proto_dir, root_abs_path + "/" + category_name, dirs_exist_ok=True, ignore=shutil.ignore_patterns("*.go")) | ||
print(f"Copied {category_name}") | ||
except OSError as exc: # python >2.5 | ||
try: | ||
shutil.copy(proto_dir, root_abs_path) | ||
print(f"File {proto_dir} copied successfully") | ||
except: | ||
raise | ||
|
||
i += 1 | ||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
{ | ||
"https://github.com/cosmos/cosmos-sdk.git": { | ||
"include": true, | ||
"branch": "v0.45.3", | ||
"paths": ["proto/cosmos"] | ||
}, | ||
"https://github.com/tendermint/tendermint.git": { | ||
"include": true, | ||
"branch": "v0.34.14", | ||
"paths": ["proto/tendermint"] | ||
}, | ||
"https://github.com/cosmos/ibc-go": { | ||
"include": true, | ||
"branch": "v3.0.0", | ||
"paths": ["proto/ibc", "third_party/proto/google"] | ||
}, | ||
"https://github.com/cosmos/cosmos-proto.git": { | ||
"include": true, | ||
"branch": "main", | ||
"paths": ["proto/cosmos_proto"] | ||
}, | ||
"https://github.com/cosmos/gogoproto.git": { | ||
"include": true, | ||
"branch": "master", | ||
"paths": ["gogoproto"] | ||
}, | ||
"https://github.com/confio/ics23.git": { | ||
"include": true, | ||
"branch": "master", | ||
"paths": ["proofs.proto"] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
{ | ||
"https://github.com/osmosis-labs/osmosis.git": { | ||
"include": true, | ||
"branch": "v10.0.0", | ||
"paths": ["proto/osmosis"] | ||
}, | ||
"https://github.com/cosmos/cosmos-sdk.git": { | ||
"include": true, | ||
"branch": "v0.45.4", | ||
"paths": ["proto/cosmos"] | ||
}, | ||
"https://github.com/tendermint/tendermint.git": { | ||
"include": true, | ||
"branch": "v0.34.19", | ||
"paths": ["proto/tendermint"] | ||
}, | ||
"https://github.com/cosmos/ibc-go": { | ||
"include": true, | ||
"branch": "v3.0.0", | ||
"paths": ["proto/ibc", "third_party/proto/google"] | ||
}, | ||
"https://github.com/cosmos/cosmos-proto.git": { | ||
"include": true, | ||
"branch": "main", | ||
"paths": ["proto/cosmos_proto"] | ||
}, | ||
"https://github.com/cosmos/gogoproto.git": { | ||
"include": true, | ||
"branch": "master", | ||
"paths": ["gogoproto"] | ||
}, | ||
"https://github.com/confio/ics23.git": { | ||
"include": true, | ||
"branch": "master", | ||
"paths": ["proofs.proto"] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,13 +4,13 @@ build-backend = "hatchling.build" | |
|
||
[project] | ||
name = "cosmospy_protobuf" | ||
version = "0.0.1" | ||
version = "0.0.2" | ||
description = "This package contains a compiled python version of all cosmos protobuf files with their dependencies" | ||
authors = [ | ||
{ name = "ctrl-felix", email = "[email protected]" }, | ||
] | ||
readme = "README.md" | ||
keywords = ["cosmospy", "proto", "cosmospy-protobuf"] | ||
keywords = ["cosmospy", "proto", "cosmospy-protobuf", "cosmos", "cosmos-protobuf", "protobuf"] | ||
license = {text = "BSD 3-Clause License"} | ||
classifiers = [ | ||
"Programming Language :: Python :: 3", | ||
|
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.