Skip to content

Commit

Permalink
fix aggregation include pattern & create release
Browse files Browse the repository at this point in the history
  • Loading branch information
ctrl-Felix committed Aug 1, 2022
1 parent bc85eca commit 0b5e3ce
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 87 deletions.
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
.idea
*.pyc
*.pyi
test/
dist/
cosmospy_protobuf.egg-info
Expand Down
21 changes: 17 additions & 4 deletions aggregate.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import errno
import json
import os
import shutil
import time
from os.path import dirname, abspath, isfile
from os.path import dirname, abspath, isfile, isdir
import fnmatch
import argparse

from git import Repo
Expand All @@ -12,6 +12,16 @@
parser.add_argument('coin', type=str, help="Coin to parse from the .json file in the config folder")
args = parser.parse_args()

# https://stackoverflow.com/questions/52071642/python-copying-the-files-with-include-pattern
def include_patterns(*patterns):
def _ignore_patterns(path, names):
keep = set(name for pattern in patterns
for name in fnmatch.filter(names, pattern))
ignore = set(name for name in names
if name not in keep and not isdir(os.path.join(path, name)))
return ignore

return _ignore_patterns
# Get current directory
d = dirname(abspath(__file__))

Expand All @@ -38,6 +48,9 @@
root_dir = 'src/cosmospy_protobuf'
root_abs_path = os.path.join(d, root_dir)
for filename in os.listdir(root_abs_path):
if filename == ".gitignore":
continue

file_path = os.path.join(root_abs_path, filename)
try:
if os.path.isfile(file_path) or os.path.islink(file_path):
Expand All @@ -63,9 +76,9 @@
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"))
shutil.copytree(proto_dir, root_abs_path + "/" + category_name, dirs_exist_ok=True, ignore=include_patterns("*.proto"))
print(f"Copied {category_name}")
except OSError as exc: # python >2.5
except OSError as exc:
try:
shutil.copy(proto_dir, root_abs_path)
print(f"File {proto_dir} copied successfully")
Expand Down
36 changes: 0 additions & 36 deletions src/cosmospy_protobuf/gogoproto/Makefile

This file was deleted.

45 changes: 0 additions & 45 deletions src/cosmospy_protobuf/gogoproto/gogo.pb.golden

This file was deleted.

0 comments on commit 0b5e3ce

Please sign in to comment.