Skip to content

Commit

Permalink
use black to reformat the code
Browse files Browse the repository at this point in the history
  • Loading branch information
laszewsk committed Dec 16, 2023
1 parent 1e37612 commit a979701
Show file tree
Hide file tree
Showing 46 changed files with 214 additions and 223 deletions.
3 changes: 2 additions & 1 deletion cloudmesh/common/DateTime.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import calendar
import datetime as TIME

import humanize as HUMANIZE
from dateutil import parser
import calendar


class DateTime(object):
Expand Down
4 changes: 2 additions & 2 deletions cloudmesh/common/DictList.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class DictList(dict):
"""

def __init__(self, entries=None, key='name', position='x'):
def __init__(self, entries=None, key="name", position="x"):
"""
initializes the DotDict List
Expand Down Expand Up @@ -80,7 +80,7 @@ def list(self):
# 'vm3': {'name': 'vm3', 'status': 'on', 'x': 2},
# 'vm4': {'name': 'vm4', 'status': 'on', 'x': 3}}

print(d['vm1'])
print(d["vm1"])
# {'name': 'vm1', 'status': 'on', 'x': 0}
#
print(d.list())
Expand Down
5 changes: 2 additions & 3 deletions cloudmesh/common/FlatDict.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import collections
import re
import yaml
import json
import os
import re

import yaml
from cloudmesh.common.util import readfile
from cloudmesh.common.util import writefile
from cloudmesh.common.variables import Variables
Expand Down Expand Up @@ -299,7 +299,6 @@ def load(self, content=None, expand=True, sep="."):
else:
config = None
self.__init__(config, sep=sep)
from cloudmesh.common.util import banner
e = expand_config_parameters(flat=self.__dict__,
expand_yaml=True,
expand_os=self.expand_os,
Expand Down
9 changes: 3 additions & 6 deletions cloudmesh/common/Host.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,14 @@
import subprocess
import textwrap
from multiprocessing import Pool
from sys import platform
from time import sleep
from random import randint
from pprint import pprint

from cloudmesh.common.DateTime import DateTime
from cloudmesh.common.Printer import Printer
from cloudmesh.common.parameter import Parameter
from cloudmesh.common.systeminfo import os_is_windows
from cloudmesh.common.util import path_expand
from cloudmesh.common.util import readfile
from cloudmesh.common.systeminfo import os_is_windows
from pprint import pprint
from cloudmesh.common.Printer import Printer


class Host(object):
Expand Down
2 changes: 1 addition & 1 deletion cloudmesh/common/Inspector.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
print(c.__cached__)

print()
print('\n'.join(c.__path__))
print("\n".join(c.__path__))


def inheritors(klass):
Expand Down
6 changes: 3 additions & 3 deletions cloudmesh/common/JobScript.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
from cloudmesh.common.JobSet import JobSet
import os
import platform
import textwrap
from cloudmesh.common.dotdict import dotdict

from cloudmesh.common.JobSet import JobSet
from cloudmesh.common.Tabulate import Printer
from cloudmesh.common.console import Console
from cloudmesh.common.dotdict import dotdict


class JobScript:
Expand Down
19 changes: 9 additions & 10 deletions cloudmesh/common/Shell.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,35 +4,34 @@
output is returned. FOr many activities in cloudmesh this is sufficient.
"""
import errno
import glob
import os
import platform as os_platform
import requests
import shlex
import shutil
import subprocess
import sys
import textwrap
import webbrowser
import zipfile
from pathlib import Path
from shlex import quote
from sys import platform
from tqdm import tqdm

import psutil
import requests
from cloudmesh.common.StopWatch import StopWatch
from cloudmesh.common.console import Console
from cloudmesh.common.dotdict import dotdict
from cloudmesh.common.systeminfo import get_platform
from cloudmesh.common.systeminfo import os_is_linux
from cloudmesh.common.systeminfo import os_is_mac
from cloudmesh.common.systeminfo import os_is_windows
from cloudmesh.common.util import is_gitbash
from cloudmesh.common.util import path_expand
from cloudmesh.common.util import readfile
from cloudmesh.common.util import writefile
from cloudmesh.common.systeminfo import os_is_windows
from cloudmesh.common.systeminfo import os_is_mac
from cloudmesh.common.systeminfo import os_is_linux
from cloudmesh.common.util import is_gitbash
from tqdm import tqdm

import shlex
from shlex import quote


# from functools import wraps
Expand Down
20 changes: 6 additions & 14 deletions cloudmesh/common/StopWatch.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,28 +87,20 @@
"""

import os
import platform
import time
import datetime
import os
import pprint
import pathlib
import yaml
import time
import sys
import os
import time
from typing import Union

from cloudmesh.common.console import Console
from cloudmesh.common.DateTime import DateTime
from cloudmesh.common.Tabulate import Printer
from cloudmesh.common.systeminfo import systeminfo as cm_systeminfo
from cloudmesh.common.util import writefile
from cloudmesh.common.util import appendfile
from cloudmesh.common.util import readfile
from cloudmesh.common.util import banner
from cloudmesh.common.DateTime import DateTime

from time import perf_counter
from typing import Union
from cloudmesh.common.util import readfile
from cloudmesh.common.util import writefile


def progress(filename=None, # +
Expand Down
20 changes: 8 additions & 12 deletions cloudmesh/common/StopWatchMllog.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,26 +172,22 @@
This method is useful when creating experiments with tools such as
cloudmesh-sbatch.
"""
import os
import platform
import time
import datetime
import pprint
import os
import pathlib
import yaml
import pprint
import sys
import time
from typing import Union

from cloudmesh.common.console import Console
import yaml
from cloudmesh.common.StopWatch import progress
from cloudmesh.common.StopWatch import progress as common_progress
from cloudmesh.common.Tabulate import Printer
from cloudmesh.common.console import Console
from cloudmesh.common.systeminfo import systeminfo as cm_systeminfo
from cloudmesh.common.util import writefile
from cloudmesh.common.util import readfile
from cloudmesh.common.DateTime import DateTime
from cloudmesh.common.StopWatch import progress
from cloudmesh.common.StopWatch import progress as common_progress

from time import perf_counter
from cloudmesh.common.util import writefile


def rename(newname):
Expand Down
63 changes: 34 additions & 29 deletions cloudmesh/common/TableParser.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,19 @@

class TableParser(object):
@classmethod
def convert(cls, table=None,
output='dict',
header=True,
index=None,
change=None,
strip=True,
lower=True,
strip_seperator=True,
seperator="|",
comment_chars="+#"):
def convert(
cls,
table=None,
output="dict",
header=True,
index=None,
change=None,
strip=True,
lower=True,
strip_seperator=True,
seperator="|",
comment_chars="+#",
):
if change is None:
change = [(":", "_"), ("(", "_"), (")", ""), ("/", "_")]
parser = TableParser(
Expand All @@ -24,25 +27,28 @@ def convert(cls, table=None,
lower=lower,
strip_seperator=strip_seperator,
seperator=seperator,
comment_chars=comment_chars)
comment_chars=comment_chars,
)
if table is not None:
if 'dict' in output:
if "dict" in output:
return parser.to_dict(table)
elif 'list' in output:
elif "list" in output:
return parser.to_dict(table)
else:
raise ValueError("output type not supported")

def __init__(self,
output='dict',
header=True,
index=None,
change=None,
strip=True,
lower=True,
strip_seperator=True,
seperator="|",
comment_chars="+#"):
def __init__(
self,
output="dict",
header=True,
index=None,
change=None,
strip=True,
lower=True,
strip_seperator=True,
seperator="|",
comment_chars="+#",
):
"""
:param header: if true the first line is a header. Not implemented
Expand Down Expand Up @@ -78,8 +84,8 @@ def clean(self, line):
:return:
"""
# print ("-" + line + "-")
if line == '':
line = 'None'
if line == "":
line = "None"
if self.is_lower:
line = line.lower()
if line == "user ": # for slurm which has "user" and "user "
Expand All @@ -88,7 +94,7 @@ def clean(self, line):
line = line.replace(convert[0], convert[1])
if self.is_strip:
line = line.strip()
return line.strip(' ')
return line.strip(" ")

def extract_lines(self, table):
lines = table.splitlines()
Expand All @@ -109,8 +115,7 @@ def _get_headers(self):
header = self.lines[0]
self.lines = self.lines[1:]

self.headers = \
[self.clean(h) for h in header.split(self.seperator)]
self.headers = [self.clean(h) for h in header.split(self.seperator)]
if self.is_strip:
self.headers = self.headers[1:-1]
return self.headers
Expand Down Expand Up @@ -175,7 +180,7 @@ def json(self):
return self.data

def __str__(self):
return json.dumps(self.data, indent=4, separators=(',', ': '))
return json.dumps(self.data, indent=4, separators=(",", ": "))


if __name__ == "__main__":
Expand Down
3 changes: 2 additions & 1 deletion cloudmesh/common/base.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import os


def directory_exists(directory_name):
# Get the current directory
current_dir = os.getcwd()
Expand All @@ -24,8 +25,8 @@ class Base:
otherwise ~/.cloudmesh is used
"""
def __init__(self, path=None, create=True):

def __init__(self, path=None, create=True):
self.key = "CLOUDMESH_CONFIG_DIR"

if path is not None:
Expand Down
3 changes: 2 additions & 1 deletion cloudmesh/common/console.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
"""
Printing messages in a console
"""
import os
import textwrap
import traceback

import colorama
from colorama import Fore, Back, Style
import os

# from cloudmesh.common.variables import Variables

Expand Down
7 changes: 4 additions & 3 deletions cloudmesh/common/debug.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
from cloudmesh.common.variables import Variables
from cloudmesh.common.util import banner
from pprint import pformat
import inspect
import os
import threading
import traceback
from pprint import pformat

from cloudmesh.common.util import banner
from cloudmesh.common.variables import Variables

verbose_lock = threading.Lock()

Expand Down
6 changes: 4 additions & 2 deletions cloudmesh/common/default.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
from cloudmesh.common.strdb import YamlDB
from cloudmesh.common.util import path_expand
from pathlib import Path

from cloudmesh.common.base import Base
from cloudmesh.common.strdb import YamlDB
from cloudmesh.common.util import path_expand


# noinspection PyPep8
class Default(object):
Expand Down
1 change: 1 addition & 0 deletions cloudmesh/common/deprecated.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import functools
import inspect
import warnings

from cloudmesh.common.console import Console

string_types = (type(b''), type(u''))
Expand Down
1 change: 1 addition & 0 deletions cloudmesh/common/error.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"""
import sys
import traceback

from cloudmesh.common.console import Console


Expand Down
Loading

0 comments on commit a979701

Please sign in to comment.