




'''simple docstring'''





import subprocess
from argparse import ArgumentParser
from typing import List, Union

from huggingface_hub.hf_api import HfFolder, create_repo, whoami
from requests.exceptions import HTTPError

from . import BaseTransformersCLICommand




class 				_snake_case	(			lowercase_							):




			@staticmethod
			def      lowerCAmelCase__       (      a__							)       ->       Union[str, Any]:

										'''simple docstring'''




										snake_case_			      =   parser.add_parser("login"       ,							help="Log in using the same credentials as on huggingface.co"							)
										login_parser.set_defaults(func=lambda a__							: LoginCommand(a__							)							)
										snake_case_			      =   parser.add_parser("whoami"       ,							help="Find out which huggingface.co account you are logged in as."							)
										whoami_parser.set_defaults(func=lambda a__							: WhoamiCommand(a__							)							)
										snake_case_			      =   parser.add_parser("logout"       ,							help="Log out"							)
										logout_parser.set_defaults(func=lambda a__							: LogoutCommand(a__							)							)

										# new system: git-based repo system
										snake_case_			      =   parser.add_parser(
										    "repo"       ,							help="Deprecated: use `huggingface-cli` instead. Commands to interact with your huggingface.co repos."       ,							)
										snake_case_			      =   repo_parser.add_subparsers(
										    help="Deprecated: use `huggingface-cli` instead. huggingface.co repos related commands"							)
										snake_case_			      =   repo_subparsers.add_parser(
										    "create"       ,							help="Deprecated: use `huggingface-cli` instead. Create a new repo on huggingface.co"							)
										repo_create_parser.add_argument(
										    "name"       ,							type=a__       ,							help="Name for your model's repo. Will be namespaced under your username to build the model id."       ,							)
										repo_create_parser.add_argument("--organization"       ,							type=a__       ,							help="Optional: organization namespace."							)
										repo_create_parser.add_argument("-y"       ,							"--yes"       ,							action="store_true"       ,							help="Optional: answer Yes to the prompt"							)
										repo_create_parser.set_defaults(func=lambda a__							: RepoCreateCommand(a__							)							)




class 				_snake_case	:
			lowerCAmelCase_  :   Any		 =					"\u001b[1m"
			lowerCAmelCase_  :   Union[str, Any]		 =					"\u001b[31m"
			lowerCAmelCase_  :   List[Any]		 =					"\u001b[90m"
			lowerCAmelCase_  :   Tuple		 =					"\u001b[0m"




			@classmethod
			def      lowerCAmelCase__       (      cls       ,							a__							)       ->       Optional[int]:

										'''simple docstring'''




										return F'{cls._bold}{s}{cls._reset}'




			@classmethod
			def      lowerCAmelCase__       (      cls       ,							a__							)       ->       int:

										'''simple docstring'''




										return F'{cls._bold}{cls._red}{s}{cls._reset}'




			@classmethod
			def      lowerCAmelCase__       (      cls       ,							a__							)       ->       Optional[int]:

										'''simple docstring'''




										return F'{cls._gray}{s}{cls._reset}'


def   UpperCamelCase_(			snake_case							: List[List[Union[str, int]]]							,       snake_case							: List[str]  ):

							'''simple docstring'''






							snake_case_			      =   [max(len(str(snake_case  )  ) for x in col  ) for col in zip(*snake_case							,       snake_case  )]
							snake_case_			      =   ("{{:{}}} " * len(snake_case  )).format(*snake_case  )
							snake_case_			      =   []
							lines.append(row_format.format(*snake_case  )  )
							lines.append(row_format.format(*["-" * w for w in col_widths]  )  )
							for row in rows:
														lines.append(row_format.format(*snake_case  )  )
							return "\n".join(snake_case  )




class 				_snake_case	:




			def __init__(      self       ,							a__							)       ->       List[Any]:

										'''simple docstring'''




										snake_case_			      =   args




class 				_snake_case	(			lowercase_							):




			def      lowerCAmelCase__       (      self							)       ->       int:

										'''simple docstring'''




										print(
										    ANSI.red(
										        "ERROR! `huggingface-cli login` uses an outdated login mechanism "
										        "that is not compatible with the Hugging Face Hub backend anymore. "
										        "Please use `huggingface-cli login instead."							)							)




class 				_snake_case	(			lowercase_							):




			def      lowerCAmelCase__       (      self							)       ->       Any:

										'''simple docstring'''




										print(
										    ANSI.red(
										        "WARNING! `transformers-cli whoami` is deprecated and will be removed in v5. Please use "
										        "`huggingface-cli whoami` instead."							)							)
										snake_case_			      =   HfFolder.get_token()
										if token is None:
																	print("Not logged in"							)
																	exit()
										try:
																	snake_case_      ,   snake_case_			      =   whoami(a__							)
																	print(a__							)
																	if orgs:
																								print(ANSI.bold("orgs: "							)       ,							",".join(a__							)							)
										except HTTPError as e:
																	print(a__							)
																	print(ANSI.red(e.response.text							)							)
																	exit(1							)




class 				_snake_case	(			lowercase_							):




			def      lowerCAmelCase__       (      self							)       ->       str:

										'''simple docstring'''




										print(
										    ANSI.red(
										        "ERROR! `transformers-cli logout` uses an outdated logout mechanism "
										        "that is not compatible with the Hugging Face Hub backend anymore. "
										        "Please use `huggingface-cli logout instead."							)							)




class 				_snake_case	(			lowercase_							):




			def      lowerCAmelCase__       (      self							)       ->       Optional[Any]:

										'''simple docstring'''




										print(
										    ANSI.red(
										        "WARNING! Managing repositories through transformers-cli is deprecated. "
										        "Please use `huggingface-cli` instead."							)							)
										snake_case_			      =   HfFolder.get_token()
										if token is None:
																	print("Not logged in"							)
																	exit(1							)
										try:
																	snake_case_			      =   subprocess.check_output(["git", "--version"]							).decode("utf-8"							)
																	print(ANSI.gray(stdout.strip()							)							)
										except FileNotFoundError:
																	print("Looks like you do not have git installed, please install."							)

										try:
																	snake_case_			      =   subprocess.check_output(["git-lfs", "--version"]							).decode("utf-8"							)
																	print(ANSI.gray(stdout.strip()							)							)
										except FileNotFoundError:
																	print(
																	    ANSI.red(
																	        "Looks like you do not have git-lfs installed, please install."
																	        " You can install from https://git-lfs.github.com/."
																	        " Then run `git lfs install` (you only have to do this once)."							)							)
										print(""							)

										snake_case_      ,   snake_case_			      =   whoami(a__							)
										snake_case_			      =   self.args.organization if self.args.organization is not None else user
										snake_case_			      =   F'{namespace}/{self.args.name}'
										print(F'You are about to create {ANSI.bold(a__							)}'							)

										if not self.args.yes:
																	snake_case_			      =   input("Proceed? [Y/n] "							).lower()
																	if not (choice == "" or choice == "y" or choice == "yes"):
																								print("Abort"							)
																								exit()
										try:
																	snake_case_			      =   create_repo(a__       ,							name=self.args.name       ,							organization=self.args.organization							)
										except HTTPError as e:
																	print(a__							)
																	print(ANSI.red(e.response.text							)							)
																	exit(1							)
										print("\nYour repo now lives at:"							)
										print(F'  {ANSI.bold(a__							)}'							)
										print("\nYou can clone it locally with the command below, and commit/push as usual."							)
										print(F'\n  git clone {url}'							)
										print(""							)








'''simple docstring'''





import os

import requests

_SCREAMING_SNAKE_CASE							:     int   	=				"https://www.amdoren.com/api/currency.php"


# Currency and their description
_SCREAMING_SNAKE_CASE							:     Optional[int]   	=				"\nAED	United Arab Emirates Dirham\nAFN	Afghan Afghani\nALL	Albanian Lek\nAMD	Armenian Dram\nANG	Netherlands Antillean Guilder\nAOA	Angolan Kwanza\nARS	Argentine Peso\nAUD	Australian Dollar\nAWG	Aruban Florin\nAZN	Azerbaijani Manat\nBAM	Bosnia & Herzegovina Convertible Mark\nBBD	Barbadian Dollar\nBDT	Bangladeshi Taka\nBGN	Bulgarian Lev\nBHD	Bahraini Dinar\nBIF	Burundian Franc\nBMD	Bermudian Dollar\nBND	Brunei Dollar\nBOB	Bolivian Boliviano\nBRL	Brazilian Real\nBSD	Bahamian Dollar\nBTN	Bhutanese Ngultrum\nBWP	Botswana Pula\nBYN	Belarus Ruble\nBZD	Belize Dollar\nCAD	Canadian Dollar\nCDF	Congolese Franc\nCHF	Swiss Franc\nCLP	Chilean Peso\nCNY	Chinese Yuan\nCOP	Colombian Peso\nCRC	Costa Rican Colon\nCUC	Cuban Convertible Peso\nCVE	Cape Verdean Escudo\nCZK	Czech Republic Koruna\nDJF	Djiboutian Franc\nDKK	Danish Krone\nDOP	Dominican Peso\nDZD	Algerian Dinar\nEGP	Egyptian Pound\nERN	Eritrean Nakfa\nETB	Ethiopian Birr\nEUR	Euro\nFJD	Fiji Dollar\nGBP	British Pound Sterling\nGEL	Georgian Lari\nGHS	Ghanaian Cedi\nGIP	Gibraltar Pound\nGMD	Gambian Dalasi\nGNF	Guinea Franc\nGTQ	Guatemalan Quetzal\nGYD	Guyanaese Dollar\nHKD	Hong Kong Dollar\nHNL	Honduran Lempira\nHRK	Croatian Kuna\nHTG	Haiti Gourde\nHUF	Hungarian Forint\nIDR	Indonesian Rupiah\nILS	Israeli Shekel\nINR	Indian Rupee\nIQD	Iraqi Dinar\nIRR	Iranian Rial\nISK	Icelandic Krona\nJMD	Jamaican Dollar\nJOD	Jordanian Dinar\nJPY	Japanese Yen\nKES	Kenyan Shilling\nKGS	Kyrgystani Som\nKHR	Cambodian Riel\nKMF	Comorian Franc\nKPW	North Korean Won\nKRW	South Korean Won\nKWD	Kuwaiti Dinar\nKYD	Cayman Islands Dollar\nKZT	Kazakhstan Tenge\nLAK	Laotian Kip\nLBP	Lebanese Pound\nLKR	Sri Lankan Rupee\nLRD	Liberian Dollar\nLSL	Lesotho Loti\nLYD	Libyan Dinar\nMAD	Moroccan Dirham\nMDL	Moldovan Leu\nMGA	Malagasy Ariary\nMKD	Macedonian Denar\nMMK	Myanma Kyat\nMNT	Mongolian Tugrik\nMOP	Macau Pataca\nMRO	Mauritanian Ouguiya\nMUR	Mauritian Rupee\nMVR	Maldivian Rufiyaa\nMWK	Malawi Kwacha\nMXN	Mexican Peso\nMYR	Malaysian Ringgit\nMZN	Mozambican Metical\nNAD	Namibian Dollar\nNGN	Nigerian Naira\nNIO	Nicaragua Cordoba\nNOK	Norwegian Krone\nNPR	Nepalese Rupee\nNZD	New Zealand Dollar\nOMR	Omani Rial\nPAB	Panamanian Balboa\nPEN	Peruvian Nuevo Sol\nPGK	Papua New Guinean Kina\nPHP	Philippine Peso\nPKR	Pakistani Rupee\nPLN	Polish Zloty\nPYG	Paraguayan Guarani\nQAR	Qatari Riyal\nRON	Romanian Leu\nRSD	Serbian Dinar\nRUB	Russian Ruble\nRWF	Rwanda Franc\nSAR	Saudi Riyal\nSBD	Solomon Islands Dollar\nSCR	Seychellois Rupee\nSDG	Sudanese Pound\nSEK	Swedish Krona\nSGD	Singapore Dollar\nSHP	Saint Helena Pound\nSLL	Sierra Leonean Leone\nSOS	Somali Shilling\nSRD	Surinamese Dollar\nSSP	South Sudanese Pound\nSTD	Sao Tome and Principe Dobra\nSYP	Syrian Pound\nSZL	Swazi Lilangeni\nTHB	Thai Baht\nTJS	Tajikistan Somoni\nTMT	Turkmenistani Manat\nTND	Tunisian Dinar\nTOP	Tonga Paanga\nTRY	Turkish Lira\nTTD	Trinidad and Tobago Dollar\nTWD	New Taiwan Dollar\nTZS	Tanzanian Shilling\nUAH	Ukrainian Hryvnia\nUGX	Ugandan Shilling\nUSD	United States Dollar\nUYU	Uruguayan Peso\nUZS	Uzbekistan Som\nVEF	Venezuelan Bolivar\nVND	Vietnamese Dong\nVUV	Vanuatu Vatu\nWST	Samoan Tala\nXAF	Central African CFA franc\nXCD	East Caribbean Dollar\nXOF	West African CFA franc\nXPF	CFP Franc\nYER	Yemeni Rial\nZAR	South African Rand\nZMW	Zambian Kwacha\n"


def   UpperCamelCase_(			snake_case							: str = "USD"							,       snake_case							: str = "INR"							,       snake_case							: float = 1.0							,       snake_case							: str = ""  ):

							'''simple docstring'''






							snake_case_			      =   locals()
							# from is a reserved keyword
							snake_case_			      =   params.pop("from_"  )
							snake_case_			      =   requests.get(snake_case							,       params=snake_case  ).json()
							return str(res["amount"]  ) if res["error"] == 0 else res["error_message"]


if __name__ == "__main__":
		_SCREAMING_SNAKE_CASE							:     Any   	=				os.getenv("CI", "")
		_SCREAMING_SNAKE_CASE							:     List[Any]   	=				os.getenv("AMDOREN_API_KEY", "")

		if not API_KEY and not TESTING:
				raise KeyError(
				    "API key must be provided in the 'AMDOREN_API_KEY' environment variable."
				)

		print(
		    convert_currency(
		        input("Enter from currency: ").strip(),
		        input("Enter to currency: ").strip(),
		        float(input("Enter the amount: ").strip()),
		        API_KEY,
		    )
		)




