Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/yedhrab/YPackage
Browse files Browse the repository at this point in the history
  • Loading branch information
yemreak committed Feb 21, 2020
1 parent baf47b1 commit dc8e703
Show file tree
Hide file tree
Showing 10 changed files with 72 additions and 21 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# 👀 What's New

## 🏷️ 2.7.3

- 🌃 Background package added
- 🎨 Colorful log added
- ✨ Logging improved

## 🏷️ 2.7.2

- 👨‍🔧 Package names fixed
Expand Down
6 changes: 4 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

README_PATH = "docs/README.md"
DYNAMIC_VERSION = False
VERSION = "2.7.2"
VERSION = "2.7.3"

if DYNAMIC_VERSION:
version = ""
Expand All @@ -28,14 +28,16 @@
author_email="[email protected]",
license='Apache Software License 2.0',
url='https://github.com/yedhrab/YPackage',
download_url=f'https://github.com/yedhrab/YPackage/archive/{version}.tar.gz',
keywords=[
'ypackage', 'yedhrab', 'yemreak', 'gitbook', 'github',
'google-search', "google", "link", "drive", "renamer", "bulk"
],
install_requires=[
"google",
"requests",
"pydriller"
"pydriller",
"coloredlogs"
],
classifiers=[
# Chose either "3 - Alpha", "4 - Beta" or "5 - Production/Stable"
Expand Down
37 changes: 37 additions & 0 deletions ypackage/background.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
from threading import Thread, Timer


def do_background(func, args=(), kwargs={}):
return Thread(target=func, args=args, kwargs=kwargs).start()


def do_delayed(func, duration, args=(), kwargs={}):
return Timer(duration, func, args, kwargs).start()


def background(func):

def inner(*args, **kwargs):
do_background(func, args=args, kwargs=kwargs)

return inner


def delayed(duration):
def background(func):

def inner(*args, **kwargs):
do_delayed(func, duration, args=args, kwargs=kwargs)

return inner
return background


if __name__ == "__main__":

@delayed(1)
def test(val1, val2):
for i in range(val1, val2):
print(i)

test(3, 20)
8 changes: 4 additions & 4 deletions ypackage/cli/file_renamer.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,10 @@ def main():
PATTERN, TO = args.pattern, args.to
SILENT = args.silent

initialize_logging()
logger = logging.getLogger(__name__)

if SILENT:
logging.basicConfig(level=logging.ERROR)
log_level = logging.ERROR if SILENT else logging.DEBUG
initialize_logging(level=log_level)

for path in PATHS:
function = rename_folders if DIR_MODE else rename_files
Expand All @@ -86,7 +86,7 @@ def main():
)

if not result:
logging.info(f"{PATTERN=} {RECURSIVE=} için değişiklik yapılmadı")
logger.warning(f"{PATTERN=} {RECURSIVE=} için değişiklik yapılmadı")


if __name__ == "__main__":
Expand Down
3 changes: 2 additions & 1 deletion ypackage/cli/gdrive.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ def main():
args = initialize_parser().parse_args()
URLS, REVERSE, DEBUG = args.urls, args.revers, args.debug

initialize_logging(detailed=DEBUG)
log_level = logging.DEBUG if DEBUG else logging.INFO
initialize_logging(level=log_level)

function = drive_to_direct if not REVERSE else direct_to_drive
for url in URLS:
Expand Down
3 changes: 2 additions & 1 deletion ypackage/cli/gsearch.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@ def main():
QUERIES, STATUS_CODE, EXCLUDE = args.queries, args.status_code, args.exclude
OUTPUT, DEBUG = args.output, args.debug

initialize_logging(detailed=DEBUG)
log_level = logging.DEBUG if DEBUG else logging.INFO
initialize_logging(level=log_level)

for query in QUERIES:
filename = re.sub(r"[^\w ]", "_", query) + ".txt" if not OUTPUT else OUTPUT
Expand Down
5 changes: 3 additions & 2 deletions ypackage/cli/integrate_into_gitbook.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from pathlib import Path
from typing import Dict

from .ort common, filesystem, gitbook, github, markdown
from .. import common, filesystem, gitbook, github, markdown

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -366,7 +366,8 @@ def main():

register_args(parser, register_all=True)

common.initialize_logging(detailed=DEBUG)
log_level = logging.DEBUG if DEBUG else logging.INFO
common.initialize_logging(level=log_level)

override_config = any([GENERATE, RECREATE, UPDATE, CHANGELOG])
for pathstr in PATHSTR_LIST:
Expand Down
2 changes: 1 addition & 1 deletion ypackage/cli/theme_creator.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ def main():
# Gettings args
PATHS, DEBUG = args.paths, args.debug

initialize_logging(detailed=DEBUG)
initialize_logging(level=DEBUG)

for path in PATHS:
path = Path(path)
Expand Down
19 changes: 11 additions & 8 deletions ypackage/common.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
import re
import logging
import re

logger = logging.getLogger(__name__)


def initialize_logging(level=logging.INFO):
import coloredlogs

def initialize_logging(detailed=False):
if detailed:
logformat = r"%(levelname)s:%(filename)s %(message)s"
loglevel = logging.DEBUG
if level == logging.DEBUG:
log_format = r"%(name)s[%(process)d] %(levelname)s %(message)s"
else:
logformat = r"%(message)s"
loglevel = logging.INFO
log_format = r"%(levelname)s %(message)s"

logging.basicConfig(format=logformat, level=loglevel)
coloredlogs.install(fmt=log_format, level=level)
logger.debug("Rekli raporlayıcı aktif edildi")


def exit_if_not(condition, message=None):
Expand Down
4 changes: 2 additions & 2 deletions ypackage/gitbook.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
SUMMARY_FILE = "SUMMARY.md"
SUMMARY_FILE_HEADER = "# Summary"

CHANGELOG_FILE = "CHANGELOG.md"
CHANGELOG_FILE = "changelog.md"
CHANGELOG_HEADER = u"👀 Neler değişti"
CONTRIBUTING_HEADER = u"💖 Katkıda Bulunma Rehberi"
GITHUB_USERNAME = "yedhrab"
Expand Down Expand Up @@ -301,7 +301,7 @@ def create_changelog(

cpath = path / CHANGELOG_FILE

filestr = "# ✨ Değişiklikler"
filestr = "# " + CHANGELOG_HEADER
filestr += "\n\n"
filestr += "## 📋 Tüm Değişiklikler"
filestr += "\n\n"
Expand Down

0 comments on commit dc8e703

Please sign in to comment.