コード例 #1
0
ファイル: datasets.py プロジェクト: gnudo/grecoman
    def initSinDirectory(self):
        '''
        This method is run when a new sinogram directory is set either
        by opening a file dialog from main.py or by copying the path
        in the respective field and pressing RETURN. If the sinogram-
        directory exists, it populates the sinogram combobox with all
        file-names or displays an error if no sinograms exist. Then it
        sets the min and max range for the sino slider.
        '''
        self.parent.sinograms.clear()  # clear sinogram combo box
        self.sinodir = os.path.join(str(self.parent.sindirectory.text()), '')

        if not os.path.exists(self.sinodir):
            self.parent.displayErrorMessage('"sin" folder missing',
                                            'No sinograms found in standard '
                                            'sin folder')
            return

        tif_list = [name for name in os.listdir(self.sinodir)
                    if name.lower().endswith('.tif') and
                    not name.startswith('.')]
        dmp_list = [name for name in os.listdir(self.sinodir)
                    if name.lower().endswith('.sin.dmp') and
                    not name.startswith('.')]

        dmp_list = tif_list + dmp_list
        dmp_list.sort()
        self.parent.sinograms.addItems(dmp_list)  # Populate sino comboxbox

        self.parent.sinoslider.setMinimum(0)
        self.parent.sinoslider.setMaximum(len(dmp_list) - 1)
        self.parent.sinoslider.setSliderPosition(0)  # Reset slider position
コード例 #2
0
ファイル: datasets.py プロジェクト: habi/grecoman
    def initSinDirectory(self):
        '''
        This method is run when a new sinogram directory is set either
        by opening a file dialog from main.py or by copying the path
        in the respective field and pressing RETURN. If the sinogram-
        directory exists, it populates the sinogram combobox with all
        file-names or displays an error if no sinograms exist. Then it
        sets the min and max range for the sino slider.
        '''
        self.parent.sinograms.clear()  # clear sinogram combo box
        self.sinodir = os.path.join(str(self.parent.sindirectory.text()), '')

        if not os.path.exists(self.sinodir):
            self.parent.displayErrorMessage('"sin" folder missing', \
                            'No sinograms found in standard sin folder')
            return

        tif_list = [name for name in os.listdir(self.sinodir)
                    if name.lower().endswith('.tif') and
                    not name.startswith('.')]
        dmp_list = [name for name in os.listdir(self.sinodir)
                    if name.lower().endswith('.sin.dmp') and not name.startswith('.')]
 
        dmp_list = tif_list + dmp_list
        dmp_list.sort()
        self.parent.sinograms.addItems(dmp_list)  # Populate sino comboxbox

        self.parent.sinoslider.setMinimum(0)
        self.parent.sinoslider.setMaximum(len(dmp_list) - 1)
        self.parent.sinoslider.setSliderPosition(0)  # Reset slider position
コード例 #3
0
def profile_loading():
    global name
    global start_weight
    global height
    global age
    global activity
    global minutes
    global male
    global cur_weight

    # personal information
    # GREG
    if -1 < name.lower().find('gr'):
        name = 'Greg'
        start_weight = 68
        height = 162
        age = 20
        activity = 3
        minutes = 60
        male = 1
    elif -1 < name.lower().find('pl'):

        # PLATO
        name = 'Plato'
        start_weight = 116
        height = 185
        age = 22
        activity = 4
        minutes = 45
        male = 1
    elif -1 < name.lower().find('br'):

        # BRAMORY
        name = 'Bramory'
        start_weight = 64
        height = 175
        age = 22
        activity = 3
        minutes = 65
        male = 1
    else:
        print(' What is your weight, kg:')
        start_weight = num_input(30, 250)
        print(' What is your height in cm:')
        height = num_input(60, 300)
        print(' What is your age in years:')
        age = num_input(10, 130)
        print(' How much workout days on a week (3, 4, 5...) :')
        activity = num_input(0, 14)
        print(' Your training session in minutes:')
        minutes = num_input(0, 300)
        print(' Are you male (y/n?) :')
        answer = input()
        if answer.find('y') or answer.find('1') or answer.find('+'):
            male = 1
        else:
            male = 0

    cur_weight = start_weight
コード例 #4
0
    def pids( check=None, name=None):
        #It currently supports Linux, Windows, OSX, FreeBSD and Sun Solaris,
        #both 32-bit and 64-bit architectures, with Python versions from 2.6 to 3.5
        #(users of Python 2.4 and 2.5 may use 2.1.3 version).
        from psutil import process_iter

        if check == "wholelist":
            print ("")
            for p in process_iter():
                try:
                    print ('\tPID: {0}  \t\t {1}'.format(p.pid,p.name()))
                except:
                    pass
            print ("")

        else:
            cache = None
            print ("")
            for p in process_iter():
                try:
                    if name.lower() in p.name().lower():
                        cache = True
                        print ('\tPID: {0}  \t\t {1}'.format(p.pid,p.name()))
                except:
                    pass
            print ("")
            if cache == None:
                print ("PID not founded for : {0} ".format(name))
コード例 #5
0
ファイル: serverMain.py プロジェクト: grillermo/Jefe-Remoto
    def adaptToOS(self):
        ''' sets the following values depending on the OS

            self.compiler : the absolute path to the compiler(PyInstaller)
            self.toCompile : the absolute path to the script to compile
            self.exeFile : the absolute path to the compiled file

            it also sets the qradiobuttons to disabled for the other os
        '''
        cwd = getcwd()
        self.localIP = self.getLocalIP()
        self.toCompile = path.join(cwd,CLIENTFILE)
        if name.lower() == 'posix':
            self.compiler = cwd+'/PyInstaller/pyinstaller.py'
            self.exeFile = cwd+'/dist/'+CLIENTFILE[:-3]+'.app'
            if platform.system() == 'Linux':
                self.exeFile = cwd+'/dist/'+CLIENTFILE[:-3]+'.deb'
        elif platform.system() == 'Windows':
            # hack to get a nice icon on the Windows
            import ctypes
            myappid = 'jefeRemoto' # arbitrary string
            ctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID(myappid)
            # #####################################
            self.compiler = cwd+'\\PyInstaller\\pyinstaller.py'
            self.exeFile = CLIENTFILE[:-3]+'.exe'
            self.exeFilePath = cwd+'\\dist\\'+self.exeFile
        return
コード例 #6
0
ファイル: commands.py プロジェクト: 52M/shellsploit-framework
def pids( check=None, name=None):
	#It currently supports Linux, Windows, OSX, FreeBSD and Sun Solaris,
	#both 32-bit and 64-bit architectures, with Python versions from 2.6 to 3.5
	#(users of Python 2.4 and 2.5 may use 2.1.3 version).
	from psutil import process_iter
	
	if check == "wholelist":
		print ("")
		for p in process_iter():
			try:
				print ('\tPID: {0}  \t\t {1}'.format(p.pid,p.name()))
			except:
				pass
		print ("")
	
	else:
		cache = None
		print ("")
		for p in process_iter():
			try:
				if name.lower() in p.name().lower():
					cache = True
					print ('\tPID: {0}  \t\t {1}'.format(p.pid,p.name()))
			except:
				pass
		print ("")
		if cache == None:
			print ("PID not founded for : {0} ".format(name))
コード例 #7
0
def validate_name():
    while True:
        name = input("\n --> ")

        if name.isalpha():
            return name.lower().capitalize()
        else:
            print("Wrong format, try again.")
            continue
コード例 #8
0
def validate_str():
    while True:
        name = input("\n --> ")

        if name.isalpha() or name == "":
            hero_name = name.lower().capitalize()
            return hero_name
        else:
            print("Wrong format, try again.")
            continue
コード例 #9
0
ファイル: core.py プロジェクト: grdvsng/EasyPing
    def __init__(self):
        ''' Method __init__ class EasyPing
            Set parameters val to platform:
                1 format OS name to default;
                2 create exemplar of converter class by platform.
                3 set special values for platform ping (count and size);
                
        '''

        name = osname.lower()
        self.converter = self.converter[name]

        self.basis['count'], self.basis['size'] = self.platform[name]
コード例 #10
0
ファイル: als.py プロジェクト: Aliens-PL/als-official
    def __do_Task(self, name, seq=None):
        print(" + Called : " + name)
        if seq:
            print("\t|_ with : " + str(seq) + "\n")
            # for a in seq:
            #     if not a.isalpha():
            #         self.isDone = False
            #         self.output = "\t+ [ "+a+" ] Must be only alphabets !"
            #         return

        if not name.isalpha():
            self.isDone = False
            self.output = "\t+ Project name [ " + name + " ] Must be only alphabets !"
            return

        name = name.lower()
        # !hardcoded , change it after please.
        if name == 'createproject':
            if possible_cmd[name][0] == seq.__len__():
                self.__create_environement(seq[0], seq[1])
            else:
                self.__create_environement(seq[0])
        elif name == 'remove':

            abs_dir = getcwd()

            if possible_cmd[name][0] == seq.__len__():
                abs_dir = path.abspath(seq[0])

            curdir = path.split(abs_dir)[-1]
            if path.exists(abs_dir + self.os_slash + curdir +
                           "_conf/global.als"):
                __import__("shutil").rmtree(abs_dir, ignore_errors=True)
            else:
                self.isDone = False
                self.output = "+ Invalid ALS directory !"

        elif name == 'run':
            if seq.__len__() >= possible_cmd[name][0]:
                self.__run_transpiler(seq[0])
            else:
                self.__run_transpiler()
        elif name == 'version':
            print(VERSION)
            exit(0)

        elif name == 'help':
            print(HP)
            exit(0)
コード例 #11
0
ファイル: main.py プロジェクト: sadra1f/herbert-text-bot
def operation(name: str, arg: list) -> bool:
    if name.lower() == 'spammer' or name.lower() == 's':
        return spam(get_index(arg, 0), get_index(arg, 1, 'int', default=1),
                    get_index(arg, 2, 'float', default=1))

    elif name.lower() == 'filespammer' or name.lower() == 'fs':
        return spam_file(get_index(arg, 0), get_index(arg, 1, 'int',
                                                      default=1),
                         get_index(arg, 2, 'float', default=1))

    elif name.lower() == 'separatedwords' or name.lower() == 'sw':
        return separate_words(get_index(arg, 0),
                              get_index(arg, 1, 'float', default=1))

    elif name.lower() == 'fileseparatedwords' or name.lower() == 'fsw':
        return separate_words_file(get_index(arg, 0),
                                   get_index(arg, 1, 'float', default=1))

    elif name.lower() == 'fileseparatedlines' or name.lower() == 'fsl':
        return separate_lines_file(get_index(arg, 0),
                                   get_index(arg, 1, 'float', default=1))

    else:
        return False
コード例 #12
0
ファイル: datasets.py プロジェクト: habi/grecoman
    def loadAndParseLogFile(self):
        '''
        This method loads the log-file and sets GUI fields automatically.
        '''
        for name in os.listdir(self.inputdir):
            if name.lower().endswith('.log') and not name.startswith('.'):
                logfile = name
                break
        else:  # if for-loop is run w/o break
            return

        logfile_handle = open(os.path.join(str(self.inputdir), logfile), 'r')
        # Go through all the lines in the logfile
        for line in logfile_handle:
            if len(line.split()) > 0:  # Only do this for existing lines
                # Scan parameters
                if (line.split()[0] == 'Number' and
                    line.split()[2] == 'projections'):
                    self.parent.raws.setText(str(line.split(':')[1]).strip())
                elif (line.split()[0] == 'Number' and
                       line.split()[2] == 'darks'):
                    self.parent.darks.setText(str(line.split(':')[1]).strip())
                elif (line.split()[0] == 'Number' and
                       line.split()[2] == 'flats'):
                    self.parent.flats.setText(str(line.split(':')[1]).strip())
                elif (line.split()[0] == 'Number' and
                       line.split()[2] == 'inter-flats'):
                    self.parent.interflats.setText(
                        str(line.split(':')[1]).strip())
                elif (line.split()[0] == 'Flat' and
                       line.split()[1] == 'frequency'):
                    self.parent.flatfreq.setText(
                        str(line.split(':')[1]).strip())
                # Beam Energy
                elif (line.split()[0] == 'Beam' and
                       line.split()[1] == 'energy'):
                    self.parent.pag_energy.setText(
                        str(line.split(':')[1]).strip())
                # Magnification and pixel size
                elif (line.split()[0] == 'Actual' and
                       line.split()[1] == 'pixel'):
                    self.parent.pag_pxsize.setText(
                        str(line.split(':')[1]).strip() + 'E-6')
                # Rotation center
                elif (line.split()[0] == 'Rotation' and
                      line.split()[1] == 'center:'):
                    self.parent.centerofrotation.setText(str(line.split(':')[1]).strip())
コード例 #13
0
def launch():
    try:
        if os_name.lower() != 'nt':
            subprocess.run([
                "python",
                path.abspath(mod_path + f"/levels/level_0{sys.argv[1]}.pyc")
            ],
                           shell=False)
        else:
            subprocess.run([
                "./venv/Scripts/python",
                path.abspath(mod_path + f"/levels/level_0{sys.argv[1]}.pyc")
            ],
                           shell=False)
    except FileNotFoundError as e:
        print(f"No level found {e.filename}")
    except Exception as e:
        pass
コード例 #14
0
def manual_setup():
    # Save path
    while True:
        workpath = lib.print_input("Enter the path you wish to save text documents to (enter curdir for current directory)")
        if workpath.lower() == 'curdir':
            if name.lower() == 'nt':
                workpath = getcwd()
            else:
                workpath = syspath[0]
        if path.isdir(workpath):
            lib.print_success("Valid Path...")
            if workpath.endswith('\\') or workpath.endswith('/'):
                pass
            else:
                if name.lower == 'nt':
                    workpath = workpath + str('\\')
                else:
                    workpath = workpath + str('/')
            break
        else:
            lib.print_error("Invalid path, check input...")
            continue
    # Looping
    while True:
        try:
            stopinput_input = lib.print_input("Run in a constant loop? [y]/[n]")
            if stopinput_input.lower() == 'y':
                stop_input = True
            elif stopinput_input.lower() == 'n':
                stop_input = int(lib.print_input("Enter the amount of successful pulls you wish to make (enter 0 for infinite)"))
            # Limiter and Cooldown
            try: limiter = int(lib.print_input("Enter the request limit you wish to use (recommended: 5)"))
            except: limiter = 5
            try: cooldown = int(lib.print_input("Enter the cooldown between IP bans/Archive scrapes (recommended: 1200)"))
            except: cooldown = 1200
            break
        except ValueError:
            lib.print_error("Invalid Input.")
            continue
    while True:
        yara_choice = lib.print_input("Enable scanning documents using YARA rules? [y/n]")
        if yara_choice.lower() not in ['y', 'n', 'yes', 'no']:
            lib.print_error("Invalid Input.")
            continue
        elif yara_choice.lower() in ['y', 'yes']:
            yara_scanning = True
            break
        elif yara_choice.lower() in ['n', 'no']:
            yara_scanning = False
            break
    # Yara Compiling
    if yara_scanning is True:
        yara_dir = f"{getcwd()}/yara_rules"
        search_rules = yara.compile(
            filepaths={f.replace(".yar", ""): path.join(f'{yara_dir}/general_rules/', f) for f in listdir(f'{yara_dir}/general_rules/') if
                       path.isfile(path.join(yara_dir, f)) and f.endswith(".yar")})
        binary_rules = yara.compile(
            filepaths={f.replace(".yar", ""): path.join(f'{yara_dir}/binary_rules/', f) for f in listdir(f'{yara_dir}/binary_rules/') if
                       path.isfile(path.join(yara_dir, f)) and f.endswith(".yar")})
    else:
        search_rules = []
        binary_rules = []
    # Saving
    while True:
        savechoice = lib.print_input('Save configuration to file for repeated use? [y]/[n]')
        if savechoice.lower() == 'n':
            break
        elif savechoice.lower() == 'y':
            configname = lib.print_input("Enter the config name (no extension)")
            try:
                with open(configname + '.ini', 'w+') as cfile:
                    cfile.write(
f"""[initial_vars]
workpath = {workpath}
stop_input = {stop_input}
limiter = {limiter}
cooldown = {cooldown}
yara_scanning = {yara_scanning}""")
                    break
            except Exception as e:
                print(f"{e}")
                break
    vars_dict = {
        'workpath': workpath,
        'stop_input': stop_input,
        'limiter': limiter,
        'cooldown': cooldown,
        'yara_scanning': yara_scanning,
        'search_rules': search_rules,
        'binary_rules': binary_rules,
    }
    try:
        print("\n")
        for x in vars_dict.keys():
            if x != 'search_rules' and x != 'binary_rules':
                if name == 'nt':
                    print(f"{x}]: {str(vars_dict[x])}")
                    print("---------------------")
                else:
                    print(f"\x1b[94m[{x}]\x1b[0m: " + f"\x1b[1;32;40m{str(vars_dict[x])}\x1b[0m")
                    print("\x1b[94m---------------------\x1b[0m")
    finally:
        print("\n")
    return vars_dict
コード例 #15
0
def show_stats(name, place="path", hero=hero_health, enemy=enemy_battle):
    # will modify in next version as it is too long and too repetitive
    header = "\033[m\033[36m[\033[36;1m "
    reset = "\033[m\033[36m"
    hero_color = stat_color(hero_health)
    enemy_color = stat_color(enemy)
    if name.lower() == "basic":
        print(
            f"{header}Hero Health{reset}: {hero_color}{str(hero[0]).zfill(3)} {reset}of {hero[1]}  |  \033[m\033[36;1mInventory{reset}: \033[32;1m {line_inventory(inventory)} {reset}]\n"
        )
    elif name[0] == "+":
        clearScreen()
        print(
            f"{reset} BATTLE versus a {name[1:].capitalize()} at the {place}\n"
        )
        print(
            f"{header}Hero Health{reset}: {hero_color}{str(hero[0]).zfill(3)} {reset}of {hero[1]}  |  \033[m\033[36;1mInventory{reset}: \033[32;1m {line_inventory(inventory)} {reset}]"
        )
        print(
            f"{healthbar(hero)} \033[33mThe {name[1:].capitalize()} hit you{reset} | \033[31;1m-{enemy[2]}\033[m"
        )
        print("\n")
        if "Glasses of Vision" in inventory or "Sacred Clam" in inventory and "Pearl of the Sacred Clam" in inventory:
            print(
                f"{header}{name[1:].capitalize()} Health{reset}: {enemy_color}{str(enemy[0]).zfill(3)} {reset}  |  \033[m\033[36;1mDroppable{reset}: \033[32;1m {line_inventory(enemy_inv)} {reset}]"
            )
            print(f"{healthbar(enemy)} \033[33m\n")
        elif "Sacred Clam" in inventory:
            print(
                f"{header}{name[1:].capitalize()} Health{reset}: ??? {reset}  |  \033[m\033[36;1mDroppable{reset}: \033[32;1m {line_inventory(enemy_inv)} {reset}]"
            )
            print(f"[ ? Unable to Sense ? {reset}] \033[33m\n")
        elif "Pearl of the Sacred Clam" in inventory:
            print(
                f"{header}{name[1:].capitalize()} Health{reset}: {enemy_color}{str(enemy[0]).zfill(3)} {reset}  |  \033[m\033[36;1mDroppable{reset}: \033[32;1m ? Unable to Sense ? {reset}]"
            )
            print(f"{healthbar(enemy)} \033[33m\n")
        else:
            print(
                f"{header}{name[1:].capitalize()} Health{reset}: ??? {reset}  |  \033[m\033[36;1mDroppable{reset}: \033[32;1m ? Unable to Sense ? {reset}]"
            )
            print(f"[ ? Unable to Sense ? {reset}] \033[33m\n")
    else:
        clearScreen()
        print(f"{reset} BATTLE versus a {name.capitalize()} at the {place}\n")
        print(
            f"{header}Hero Health{reset}: {hero_color}{str(hero[0]).zfill(3)} {reset}of {hero[1]}  |  \033[m\033[36;1mInventory{reset}: \033[32;1m {line_inventory(inventory)} {reset}]"
        )
        print(f"{healthbar(hero)} \033[33m")
        print("\n")
        if "Glasses of Vision" in inventory or "Sacred Clam" in inventory and "Pearl of the Sacred Clam" in inventory:
            print(
                f"{header}{name.capitalize()} Health{reset}: {enemy_color}{str(enemy[0]).zfill(3)} {reset}  |  \033[m\033[36;1mDroppable{reset}: \033[32;1m {line_inventory(enemy_inv)} {reset}]"
            )
            print(
                f"{healthbar(enemy)} \033[33mYou hit the {name}{reset} | \033[31;1m-{hero[2]}\033[m\n"
            )
        elif "Sacred Clam" in inventory:
            print(
                f"{header}{name.capitalize()} Health{reset}: ??? {reset}  |  \033[m\033[36;1mDroppable{reset}: \033[32;1m {line_inventory(enemy_inv)} {reset}]"
            )
            print(
                f"[ ? Unable to Sense ? {reset}] \033[33mYou hit the {name}{reset} | \033[31;1m-{hero[2]}\033[m\n"
            )
        elif "Pearl of the Sacred Clam" in inventory:
            print(
                f"{header}{name.capitalize()} Health{reset}: {enemy_color}{str(enemy[0]).zfill(3)} {reset}  |  \033[m\033[36;1mDroppable{reset}: \033[32;1m ? Unable to Sense ? {reset}]"
            )
            print(
                f"{healthbar(enemy)} \033[33mYou hit the {name}{reset} | \033[31;1m-{hero[2]}\033[m\n"
            )
        else:
            print(
                f"{header}{name.capitalize()} Health{reset}: ??? {reset}  |  \033[m\033[36;1mDroppable{reset}: \033[32;1m ? Unable to Sense ? {reset}]"
            )
            print(
                f"[ ? Unable to Sense ? {reset}] \033[33mYou hit the {name}{reset} | \033[31;1m-{hero[2]}\033[m\n"
            )
    time.sleep(1)
コード例 #16
0
from math import sin, cos, sqrt, atan2, radians
from random import randint
from time import sleep
from pickle import dump as pdump
from pickle import load as pload
from os import system, getcwd
from os import name as osname
from data import *


if osname.lower() == 'nt':
    clear = 'cls'
    viewDir = 'dir /b'
    slash = '\\'
else:
    clear = 'clear'
    viewDir = 'ls'
    slash = '/'


class Player(object):
    def __init__(self, name, color='std'):
        self.name = name
        self.color = color
        self.gold = SV['gold']
        self.multiplier = SV['multiplier']

        self.trains = [] 
        # {"from": str, "to": str, "name": str, "distance": int, "cargoOut": list, "cargoIn": list, "currentCity": str}

        self.buildQueue = []
コード例 #17
0
def printB(s, r=0):
    nix = name.lower() != "nt"
    s = '\033[1m' * nix + s + '\033[0m' * nix
    if r:
        return s
    print(s)
コード例 #18
0
ファイル: setup.py プロジェクト: Nargott/ArtefactReactor
except:
    print('WARNING: You do not have Cython installed. Installation preceeding without Cython.')
    cmdclass={'install': install}
    has_cython = False
# You will also need NumPy to compile this Cython
try:
    import numpy as np
except:
    print('WARNING: You do not have NumPy installed. Installation preceeding without Cython.')
    has_cython = False

# find all the extension modules in the project, for a Cython build
if has_cython:
    FORCE_FLAGS = ['-f', '--f', '--force']
    FORCE_REBUILD = True if any([f in argv for f in FORCE_FLAGS]) else False
    IS_WINDOWS = True if (os_name.lower() == 'nt' or 'win' in platform.lower()) else False
    COMP_DIRS = {'language_level': 3, 'boundscheck': False, 'initializedcheck': False, 'cdivision': True}
    sep = '\\' if IS_WINDOWS else '/'
    ext_modules = [Extension(p[:-4].replace(sep, '.'), [p, p[:-2] + 'y'], include_dirs=[np.get_include(), '.'])
                   for p in glob(sep.join(['mazelib', '*', '*.pxd']))]
    ext_modules_list = cythonize(ext_modules, annotate=False, force=FORCE_REBUILD, compiler_directives=COMP_DIRS)
else:
    ext_modules_list = []


# perform the actual build/install
setup(
    cmdclass=cmdclass,
    name='mazelib',
    version=__version__,
    description='A Python API for creating and solving mazes.',
コード例 #19
0
ファイル: __init__.py プロジェクト: gromenauer/manga-py
def is_windows():
    if ~os_name.lower().find('nt'):
        return True
    return False
コード例 #20
0
ファイル: __init__.py プロジェクト: BackupTheBerlios/pds-svn
def _creator(name):
    return lambda options : \
        __import__(__name__ + "." + options[name.lower()]["type"],{}, {}, name) \
        .__dict__[name](options[name.lower()])
コード例 #21
0
ファイル: setup.py プロジェクト: theJollySin/mazelib
'''
from setuptools import setup, find_packages
from setuptools.command.install import install
from distutils.extension import Extension
from Cython.Distutils import build_ext
from Cython.Build import cythonize
from glob import glob
import numpy as np
from os import name as os_name
from sys import argv, platform
from mazelib import __version__

# CONSTANTS
FORCE_FLAGS = ['-f', '--f', '--force']
FORCE_REBUILD = True if any([f in argv for f in FORCE_FLAGS]) else False
IS_WINDOWS = True if (os_name.lower() == 'nt' or 'win' in platform.lower()) else False
COMP_DIRS = {'language_level': 3, 'boundscheck': False, 'initializedcheck': False, 'cdivision': True}

# find all the extension modules in the project
sep = '\\' if IS_WINDOWS else '/'
ext_modules = [Extension(p[:-4].replace(sep, '.'), [p, p[:-2] + 'y'], include_dirs=[np.get_include(), '.'])
               for p in glob(sep.join(['mazelib', '*', '*.pxd']))]


# perform the actual build/install
setup(
    cmdclass={
        'install': install,
        'build_ext': build_ext,
    },
    name='mazelib',
コード例 #22
0
    cmdclass = {'install': install}
    has_cython = False
# You will also need NumPy to compile this Cython
try:
    import numpy as np
except (ModuleNotFoundError, ImportError):
    print(
        'WARNING: You do not have NumPy installed. Installation preceeding without NumPy.'
    )
    has_cython = False

# find all the extension modules in the project, for a Cython build
if has_cython:
    FORCE_FLAGS = ['-f', '--f', '--force']
    FORCE_REBUILD = True if any([f in argv for f in FORCE_FLAGS]) else False
    IS_WINDOWS = True if (os_name.lower() == 'nt'
                          or 'win' in platform.lower()) else False
    COMP_DIRS = {
        'language_level': 3,
        'boundscheck': False,
        'initializedcheck': False,
        'cdivision': True
    }
    sep = '\\' if IS_WINDOWS else '/'
    ext_modules = [
        Extension(p[:-4].replace(sep, '.'), [p, p[:-2] + 'y'],
                  include_dirs=[np.get_include(), '.'])
        for p in glob(sep.join(['mazelib', '*', '*.pxd']))
    ]
    ext_modules_list = cythonize(ext_modules,
                                 annotate=False,
コード例 #23
0
def clear_screen():
    if 'windows' in sys_name.lower():
        system('cls')
    else:
        system('clear')