# Coverage for __main__.py : 0%

## 29 statements

Hot-keys on this page

r m x p toggle line displays

j k next/prev highlighted chunk

0 (zero) top of page

1 (one) first highlighted chunk

1 import re

2 import subprocess

3 import sys

4 from pathlib import Path

5

6 from shopyo.api.info import printinfo

7

8 dirpath = Path(__file__).parent.absolute()

9 dirpathparent = Path(__file__).parent.parent.absolute()

10

11

12 def is_venv():

13 return hasattr(sys, "real_prefix") or (

14 hasattr(sys, "base_prefix") and sys.base_prefix != sys.prefix

15 )

16

17

18 def is_valid_name(name):

19 notallowedpattern = r"[_\.]+"

20 allowedpattern = r"^[\w+\.]+$"

21 isallowed = re.match(allowedpattern, name)

22 isnotallowed = re.match(notallowedpattern, name)

23

24 if not isnotallowed and isallowed:

25 return True

26 else:

27 return False

28

29

30 def main():

31 args = sys.argv

32 if len(args) == 1:

33 printinfo()

34 print("No arguments supplied")

35 else:

36 if not is_venv():

37 print("Please use Shopyo in a virtual environment for this command")

38 sys.exit()

39 torun = [sys.executable, "manage.py"] + args[1:]

40 subprocess.run(torun)

41

42

43 if __name__ == "__main__":

44 main()