mkdirPypi.py 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. #********************************************************************************#
  2. # #
  3. # нεℓℓσ,вαтεs! #
  4. # #
  5. # filename: mkdirPypi.py #
  6. # created: 2022-03-10 #
  7. # system: Windows #
  8. # version: 64bit #
  9. # by: Bates <https://github.com/batestin1> #
  10. #********************************************************************************#
  11. # import your librarys below #
  12. #********************************************************************************#
  13. from pathlib import Path
  14. from datetime import date
  15. import getpass
  16. import platform
  17. import subprocess
  18. def mkdirPypi(file):
  19. users=getpass.getuser()
  20. res = subprocess.run(["git", "config", "user.name"], stdout=subprocess.PIPE)
  21. git_username = res.stdout.strip().decode()
  22. filename = file.replace(' ', '_')
  23. #create a home directory#
  24. cd = 'Codigo fonte'
  25. dw = 'Download'
  26. linkGit = f'https://github.com/{git_username}/'
  27. codigo_fonte = f"{cd} : {linkGit}"
  28. download = f"{dw} : {linkGit}"
  29. project_urls = {codigo_fonte, download}
  30. path = Path(f"./{filename}")
  31. path.mkdir(parents=True, exist_ok=True)
  32. data_atual = date.today()
  33. data = f"""{data_atual.strftime('%Y-%m-%d')}"""
  34. #### create a LICENSE ####
  35. textLic ="""
  36. MIT License
  37. Copyright (c) 2018 Yan Orestes
  38. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge,publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
  39. """
  40. licensa = open(f"{filename}/LICENSE", "w")
  41. licensa.write(textLic)
  42. #### create a README.md ###
  43. textReadm = f"""
  44. <h1 align="center">
  45. <img src="https://img.shields.io/static/v1?label={filename.upper()}%20POR&message={users}&color=7159c1&style=flat-square&logo=ghost"/>
  46. <h3> <p align="center">{filename.upper()} </p> </h3>
  47. <h3> <p align="center"> ================= </p> </h3>
  48. >> <h3> Resume </h3>
  49. <p> text here </p>
  50. >> <h3> How install </h3>
  51. ```
  52. code here
  53. ```
  54. >> <h3> How Works </h3>
  55. ```
  56. code here
  57. ```
  58. """
  59. readme = open(f"{filename}/README.md", "w")
  60. readme.write(textReadm)
  61. ###setup.cfg###
  62. cfgTxt = """
  63. [metadata]
  64. description-file = README.md
  65. license_file = LICENSE.txt
  66. """
  67. cfgsetup = open(f"{filename}/setup.cfg", "w")
  68. cfgsetup.write(cfgTxt)
  69. ###setup.py ######
  70. setupyT = f"""
  71. from setuptools import setup
  72. setup(
  73. name = '{filename}',
  74. version = '1.0.0',
  75. author = '{users}',
  76. author_email = '{users}@mailer.com.br',
  77. packages = ['{filename}'],
  78. description = 'a way to make your life easier',
  79. long_description = 'file: README.md',
  80. url = 'https://github.com/{git_username}/',
  81. project_urls = {project_urls},
  82. keywords = 'a way to make your life easier',
  83. classifiers = []
  84. )"""
  85. setupy = open(f"{filename}/setup.py", "w")
  86. setupy.write(setupyT)
  87. #### create dir #####
  88. path = Path(f"./{filename}/{filename}")
  89. path.mkdir(parents=True, exist_ok=True)
  90. txtnull=f"""
  91. #############################################################################################################################
  92. # filename:{filename}.py
  93. # created: {data}
  94. # import your librarys below
  95. #############################################################################################################################
  96. def {filename}():
  97. pass
  98. """
  99. main = open(f"{filename}/{filename}/{filename}.py", "w")
  100. main.write(txtnull)
  101. txtnull2=f"""
  102. #############################################################################################################################
  103. # filename:{filename}.py
  104. # created: {data}
  105. # import your librarys below
  106. #############################################################################################################################
  107. from .{filename} import *
  108. """
  109. init = open(f"{filename}/{filename}/__init__.py", "w")
  110. init.write(txtnull2)
  111. print(f"your project call {filename} was create to be upper on Pypi")