





import os
import random
import sys

from . import cryptomath_module as cryptomath
from . import rabin_miller

UpperCamelCase__     =	3





def       _UpperCamelCase       (a__				:int    ):






							"""simple docstring"""





							print("""Generating primitive root of p"""    )
							while True:
														UpperCamelCase__			       =     random.randrange(3				,     a__    )
														if pow(a__				,     2				,     a__    ) == 1:
																					continue
														if pow(a__				,     a__				,     a__    ) == 1:
																					continue
														return g





def       _UpperCamelCase       (a__				:int    ):






							"""simple docstring"""





							print("""Generating prime p..."""    )
							UpperCamelCase__			       =     rabin_miller.generate_large_prime(a__    )  # select large prime number.
							UpperCamelCase__			       =     primitive_root(a__    )  # one primitive root on modulo p.
							UpperCamelCase__			       =     random.randrange(3				,     a__    )  # private_key -> have to be greater than 2 for safety.
							UpperCamelCase__			       =     cryptomath.find_mod_inverse(pow(a__				,     a__				,     a__    )				,     a__    )

							UpperCamelCase__			       =     (key_size, e_a, e_a, p)
							UpperCamelCase__			       =     (key_size, d)

							return public_key, private_key





def       _UpperCamelCase       (a__				:str				,     a__				:int    ):






							"""simple docstring"""





							if os.path.exists(f"""{name}_pubkey.txt"""    ) or os.path.exists(f"""{name}_privkey.txt"""    ):
														print("""\nWARNING:"""    )
														print(
														    f"""\"{name}_pubkey.txt\" or \"{name}_privkey.txt\" already exists. \n"""
														    """Use a different name or delete these files and re-run this program."""    )
														sys.exit()

							UpperCamelCase__       ,       UpperCamelCase__			       =     generate_key(a__    )
							print(f"""\nWriting public key to file {name}_pubkey.txt..."""    )
							with open(f"""{name}_pubkey.txt"""				,     """w"""    ) as fo:
														fo.write(f"""{public_key[0]},{public_key[1]},{public_key[2]},{public_key[3]}"""    )

							print(f"""Writing private key to file {name}_privkey.txt..."""    )
							with open(f"""{name}_privkey.txt"""				,     """w"""    ) as fo:
														fo.write(f"""{private_key[0]},{private_key[1]}"""    )





def       _UpperCamelCase       ():






							"""simple docstring"""





							print("""Making key files..."""    )
							make_key_files("""elgamal"""				,     2048    )
							print("""Key files generation successful"""    )


if __name__ == "__main__":
						main()











from datetime import datetime as dt
import os

from github import Github


UpperCamelCase__     =	[
    "good first issue",
    "good second issue",
    "good difficult issue",
    "feature request",
    "new model",
    "wip",
]





def       _UpperCamelCase       ():






							"""simple docstring"""





							UpperCamelCase__			       =     Github(os.environ["""GITHUB_TOKEN"""]    )
							UpperCamelCase__			       =     g.get_repo("""huggingface/transformers"""    )
							UpperCamelCase__			       =     repo.get_issues(state="""open"""    )

							for issue in open_issues:
														UpperCamelCase__			       =     sorted([comment for comment in issue.get_comments()]				,     key=lambda a__    : i.created_at				,     reverse=a__    )
														UpperCamelCase__			       =     comments[0] if len(a__    ) > 0 else None
														if (
														    last_comment is not None
														    and last_comment.user.login == "github-actions[bot]"
														    and (dt.utcnow() - issue.updated_at).days > 7
														    and (dt.utcnow() - issue.created_at).days >= 30
														    and not any(label.name.lower() in LABELS_TO_EXEMPT for label in issue.get_labels()    )
														):
																					# print(f"Would close issue {issue.number} since it has been 7 days of inactivity since bot mention.")
																					issue.edit(state="""closed"""    )
														elif (
														    (dt.utcnow() - issue.updated_at).days > 23
														    and (dt.utcnow() - issue.created_at).days >= 30
														    and not any(label.name.lower() in LABELS_TO_EXEMPT for label in issue.get_labels()    )
														):
																					# print(f"Would add stale comment to {issue.number}")
																					issue.create_comment(
																					    """This issue has been automatically marked as stale because it has not had """
																					    """recent activity. If you think this still needs to be addressed """
																					    """please comment on this thread.\n\nPlease note that issues that do not follow the """
																					    """[contributing guidelines](https://github.com/huggingface/transformers/blob/main/CONTRIBUTING.md) """
																					    """are likely to be ignored."""    )


if __name__ == "__main__":
					main()




