From 7d78299b31c803fd904b59bf60c652041a20fbb1 Mon Sep 17 00:00:00 2001 From: pramod-199 <146347894+pramod-199@users.noreply.github.com> Date: Thu, 4 Apr 2024 12:23:43 +0000 Subject: [PATCH] practice till 04-04-24 --- Day-02/examples/01-string-len.py | 4 + Day-02/examples/01-string-lowercase.py | 41 +++- Day-02/examples/01-string-replace.py | 15 ++ Day-02/examples/01-string-split.py | 49 +++++ Day-02/examples/01-string-substring.py | 11 ++ Day-02/examples/02-float.py | 4 +- Day-02/examples/02-int.py | 9 + Day-02/examples/03-regex-findall.py | 9 + Day-02/examples/03-regex-match.py | 3 +- Day-02/examples/03-regex-replace.py | 8 + Day-02/examples/03-regex-search.py | 10 +- Day-02/examples/replace.py | 14 ++ Day-02/terraform/test.tf | 14 ++ Day-02/test.py | 19 ++ Day-03/float.py | 20 ++ Day-03/test.py | 21 +++ Day-04/advance_cal.py | 22 +++ Day-04/calculator.py | 11 ++ Day-04/calculator_new.py | 24 +++ Day-04/calling_module.py | 24 +++ Day-04/modules/functions.py | 25 +++ Day-04/project-abc/bin/Activate.ps1 | 247 +++++++++++++++++++++++++ Day-04/project-abc/bin/activate | 69 +++++++ Day-04/project-abc/bin/activate.csh | 26 +++ Day-04/project-abc/bin/activate.fish | 69 +++++++ Day-04/project-abc/bin/jirashell | 8 + Day-04/project-abc/bin/normalizer | 8 + Day-04/project-abc/bin/pip | 8 + Day-04/project-abc/bin/pip3 | 8 + Day-04/project-abc/bin/pip3.10 | 8 + Day-04/project-abc/bin/python | 1 + Day-04/project-abc/bin/python3 | 1 + Day-04/project-abc/bin/python3.10 | 1 + Day-04/project-abc/lib64 | 1 + Day-04/project-abc/pyvenv.cfg | 3 + Day-04/project-xyz/bin/Activate.ps1 | 247 +++++++++++++++++++++++++ Day-04/project-xyz/bin/activate | 69 +++++++ Day-04/project-xyz/bin/activate.csh | 26 +++ Day-04/project-xyz/bin/activate.fish | 69 +++++++ Day-04/project-xyz/bin/jirashell | 8 + Day-04/project-xyz/bin/keyring | 8 + Day-04/project-xyz/bin/normalizer | 8 + Day-04/project-xyz/bin/pip | 8 + Day-04/project-xyz/bin/pip3 | 8 + Day-04/project-xyz/bin/pip3.10 | 8 + Day-04/project-xyz/bin/python | 1 + Day-04/project-xyz/bin/python3 | 1 + Day-04/project-xyz/bin/python3.10 | 1 + Day-04/project-xyz/lib64 | 1 + Day-04/project-xyz/pyvenv.cfg | 3 + 50 files changed, 1276 insertions(+), 5 deletions(-) create mode 100644 Day-02/examples/replace.py create mode 100644 Day-02/terraform/test.tf create mode 100644 Day-02/test.py create mode 100644 Day-03/float.py create mode 100644 Day-03/test.py create mode 100644 Day-04/advance_cal.py create mode 100644 Day-04/calculator.py create mode 100644 Day-04/calculator_new.py create mode 100644 Day-04/calling_module.py create mode 100644 Day-04/modules/functions.py create mode 100644 Day-04/project-abc/bin/Activate.ps1 create mode 100644 Day-04/project-abc/bin/activate create mode 100644 Day-04/project-abc/bin/activate.csh create mode 100644 Day-04/project-abc/bin/activate.fish create mode 100755 Day-04/project-abc/bin/jirashell create mode 100755 Day-04/project-abc/bin/normalizer create mode 100755 Day-04/project-abc/bin/pip create mode 100755 Day-04/project-abc/bin/pip3 create mode 100755 Day-04/project-abc/bin/pip3.10 create mode 120000 Day-04/project-abc/bin/python create mode 120000 Day-04/project-abc/bin/python3 create mode 120000 Day-04/project-abc/bin/python3.10 create mode 120000 Day-04/project-abc/lib64 create mode 100644 Day-04/project-abc/pyvenv.cfg create mode 100644 Day-04/project-xyz/bin/Activate.ps1 create mode 100644 Day-04/project-xyz/bin/activate create mode 100644 Day-04/project-xyz/bin/activate.csh create mode 100644 Day-04/project-xyz/bin/activate.fish create mode 100755 Day-04/project-xyz/bin/jirashell create mode 100755 Day-04/project-xyz/bin/keyring create mode 100755 Day-04/project-xyz/bin/normalizer create mode 100755 Day-04/project-xyz/bin/pip create mode 100755 Day-04/project-xyz/bin/pip3 create mode 100755 Day-04/project-xyz/bin/pip3.10 create mode 120000 Day-04/project-xyz/bin/python create mode 120000 Day-04/project-xyz/bin/python3 create mode 120000 Day-04/project-xyz/bin/python3.10 create mode 120000 Day-04/project-xyz/lib64 create mode 100644 Day-04/project-xyz/pyvenv.cfg diff --git a/Day-02/examples/01-string-len.py b/Day-02/examples/01-string-len.py index ff0fafe6..52ce7fbe 100644 --- a/Day-02/examples/01-string-len.py +++ b/Day-02/examples/01-string-len.py @@ -1,3 +1,7 @@ text = "Python is awesome" length = len(text) print("Length of the string:", length) + +test = "aarna is good company" +length1 = len(test) +print("length of the string:", length1) \ No newline at end of file diff --git a/Day-02/examples/01-string-lowercase.py b/Day-02/examples/01-string-lowercase.py index 7f7c810a..982dae28 100644 --- a/Day-02/examples/01-string-lowercase.py +++ b/Day-02/examples/01-string-lowercase.py @@ -1,5 +1,44 @@ -text = "Python is awesome" +text = "Python is Awesome" uppercase = text.upper() lowercase = text.lower() print("Uppercase:", uppercase) print("Lowercase:", lowercase) + + + + + + + + + + + + +test = "king is always KING" +upper1 = test.upper() +lower1 = test.lower() +print("UPPERCASE:", upper1) +print("lower:", lower1) + + + + + + + + + + + + + + + + + +aarna = "aarna is good COMPANY" +upper2 = aarna.upper() +lower2 = aarna.lower() +print("Uppercase:", upper2) +print("Lowercase:", lower2) diff --git a/Day-02/examples/01-string-replace.py b/Day-02/examples/01-string-replace.py index d6d08f5a..d8838255 100644 --- a/Day-02/examples/01-string-replace.py +++ b/Day-02/examples/01-string-replace.py @@ -1,3 +1,18 @@ text = "Python is awesome" new_text = text.replace("awesome", "great") print("Modified text:", new_text) + + + + + + + + + + + + +test = "pramod is awesome Muktawar" +new_cn = test.replace("pramod", "prasad") +print("modified:", new_cn) \ No newline at end of file diff --git a/Day-02/examples/01-string-split.py b/Day-02/examples/01-string-split.py index 3a61b5d4..e605f446 100644 --- a/Day-02/examples/01-string-split.py +++ b/Day-02/examples/01-string-split.py @@ -1,3 +1,52 @@ text = "Python is awesome" words = text.split() print("Words:", words) + + + + + + + + + + + + + + + + + +test = "pramod is muktawar" +new = test.split() +print("Words:", new) + + + + + + + + + + + +test1 = "king is slave" +# Split the string into words +words = test1.split() + +# Convert each word to uppercase and store it in a list +upper_words = [word.upper() for word in words] + +# Join the uppercase words back into a string +result = " ".join(upper_words) + +print("Uppercase words:", result) + + + + + + + diff --git a/Day-02/examples/01-string-substring.py b/Day-02/examples/01-string-substring.py index 97420515..e202fc6c 100644 --- a/Day-02/examples/01-string-substring.py +++ b/Day-02/examples/01-string-substring.py @@ -2,3 +2,14 @@ substring = "is" if substring in text: print(substring, "found in the text") + + + + test = "pramod was king" + substring1 = "pramod" + if substring1 in test: + print(substring1, "found in test" ) + + + result = substring1 + " " + substring + print("addition:", result) diff --git a/Day-02/examples/02-float.py b/Day-02/examples/02-float.py index 8d6264c4..fa2737d0 100644 --- a/Day-02/examples/02-float.py +++ b/Day-02/examples/02-float.py @@ -1,5 +1,5 @@ # Float variables -num1 = 5.0 +num1 = 5.1499 num2 = 2.5 # Basic Arithmetic @@ -16,5 +16,5 @@ print("Division:", result4) # Rounding -result5 = round(3.14159265359, 2) # Rounds to 2 decimal places +result5 = round(result4, 2) # Rounds to 2 decimal places print("Rounded:", result5) diff --git a/Day-02/examples/02-int.py b/Day-02/examples/02-int.py index bd5aa178..eb45bfa0 100644 --- a/Day-02/examples/02-int.py +++ b/Day-02/examples/02-int.py @@ -13,3 +13,12 @@ # Absolute Value result3 = abs(-7) print("Absolute Value:", result3) + +result4 = num1 * num2 +print("multiplication:", result4) + +result5 = num1 - num2 +print("substraction:", result5) + +result6 = abs(-55) +print("abbstraction:", result6) diff --git a/Day-02/examples/03-regex-findall.py b/Day-02/examples/03-regex-findall.py index ec5cdd5c..5a8ec8a6 100644 --- a/Day-02/examples/03-regex-findall.py +++ b/Day-02/examples/03-regex-findall.py @@ -8,3 +8,12 @@ print("Pattern found:", search.group()) else: print("Pattern not found") + +test = "hi i am pramod muktawar" +pattern1 = r"pramod" + +search1 = re.search(pattern1, test) +if search1: + print("pattern found:", search1.group()) +else: + print("pattern not found") diff --git a/Day-02/examples/03-regex-match.py b/Day-02/examples/03-regex-match.py index b3aafdd1..ff819d03 100644 --- a/Day-02/examples/03-regex-match.py +++ b/Day-02/examples/03-regex-match.py @@ -1,6 +1,6 @@ import re -text = "The quick brown fox" +text = " brown quick fox" pattern = r"quick" match = re.match(pattern, text) @@ -8,3 +8,4 @@ print("Match found:", match.group()) else: print("No match") + diff --git a/Day-02/examples/03-regex-replace.py b/Day-02/examples/03-regex-replace.py index 2fea32da..9cd49a86 100644 --- a/Day-02/examples/03-regex-replace.py +++ b/Day-02/examples/03-regex-replace.py @@ -7,3 +7,11 @@ new_text = re.sub(pattern, replacement, text) print("Modified text:", new_text) + + + +test = "the cow is black and calf is also black." +pattern1 = r"black" +replacement1 = "white" +test1 = re.sub(pattern1, replacement1, test) +print("modified text:", test1) \ No newline at end of file diff --git a/Day-02/examples/03-regex-search.py b/Day-02/examples/03-regex-search.py index ec5cdd5c..923d8daa 100644 --- a/Day-02/examples/03-regex-search.py +++ b/Day-02/examples/03-regex-search.py @@ -1,10 +1,18 @@ import re -text = "The quick brown fox" +text = " brown The quick brown fox" pattern = r"brown" +replacement = "red" +pattern1 = " , " search = re.search(pattern, text) if search: print("Pattern found:", search.group()) else: print("Pattern not found") + +new = re.sub(pattern, replacement, text) +print("modified text:", new) + +new1 = re.split(pattern1, new) +print("split result:", new1) \ No newline at end of file diff --git a/Day-02/examples/replace.py b/Day-02/examples/replace.py new file mode 100644 index 00000000..b3699bb6 --- /dev/null +++ b/Day-02/examples/replace.py @@ -0,0 +1,14 @@ +import re + +text = "aarna is bad company with good peoples" +pattern = r"good" +replacement = "bad" + +patterrn1 = r"bad" +replacement1 = "good" + +new = re.sub(pattern, replacement, text) + +new1 = re.sub(patterrn1, replacement1, new) + +print("Modified text:", new1) \ No newline at end of file diff --git a/Day-02/terraform/test.tf b/Day-02/terraform/test.tf new file mode 100644 index 00000000..d8f83f22 --- /dev/null +++ b/Day-02/terraform/test.tf @@ -0,0 +1,14 @@ +variable "name" { + type = string + +} + +variable "age" { + type = number + +} + +output "info" { + value = "my name is ${var.name} and my age is ${var.age}" + +} \ No newline at end of file diff --git a/Day-02/test.py b/Day-02/test.py new file mode 100644 index 00000000..09d438b1 --- /dev/null +++ b/Day-02/test.py @@ -0,0 +1,19 @@ +arn = "arn:aws:iam::123456789012:user/Development/product_1234/" +name = "pramod" +sur = "MUKTAWAR" + +print(arn.split("/")[3]) +print(arn.split(":")) + + +print(name.upper()) +print(sur.lower()) + +num1 = 2.05555 +num2 = 3.55558 + +result = num1 + num2 +print("addition:", result) + +result1 = round(result, 2) +print("round of:", result1) diff --git a/Day-03/float.py b/Day-03/float.py new file mode 100644 index 00000000..fa2737d0 --- /dev/null +++ b/Day-03/float.py @@ -0,0 +1,20 @@ +# Float variables +num1 = 5.1499 +num2 = 2.5 + +# Basic Arithmetic +result1 = num1 + num2 +print("Addition:", result1) + +result2 = num1 - num2 +print("Subtraction:", result2) + +result3 = num1 * num2 +print("Multiplication:", result3) + +result4 = num1 / num2 +print("Division:", result4) + +# Rounding +result5 = round(result4, 2) # Rounds to 2 decimal places +print("Rounded:", result5) diff --git a/Day-03/test.py b/Day-03/test.py new file mode 100644 index 00000000..e0b9d080 --- /dev/null +++ b/Day-03/test.py @@ -0,0 +1,21 @@ +a = 50 +b = 5 + +def add(): + a = 10 + b = 20 + print(a + b) + + + +def sub(): + c = 5 + b = 30 + print(a - b - c ) + +def kill(): + print(a * b) + +kill() +add() +sub() \ No newline at end of file diff --git a/Day-04/advance_cal.py b/Day-04/advance_cal.py new file mode 100644 index 00000000..8f869f93 --- /dev/null +++ b/Day-04/advance_cal.py @@ -0,0 +1,22 @@ +import calculator_new as basic_cal # as works as alis and we are giving alis name to calculator_new as basic_cal + +#calculator_new is already devloped program so we are calling it i here as module to call module in here keyword is import +#module is nothing but group of functions + +num = 4 +num = 2 + +basic_cal.adition() + +#now we are importing module from different location here it how to do + +import sys +sys.path.append('/workspaces/python-for-devops/Day-03/') #this is path to module to call in this script +import float as floatc #creating alias name +#while giving path to module just give file name dont provide extension + +floatc + +from calculator_new import abbstraction #this is used fro calling only specific funtion from module + +abbstraction() \ No newline at end of file diff --git a/Day-04/calculator.py b/Day-04/calculator.py new file mode 100644 index 00000000..5db97b89 --- /dev/null +++ b/Day-04/calculator.py @@ -0,0 +1,11 @@ +#num = 6 +#num1 = 3 + +add = num + num1 +print("addition value", add) + +sub = num - num1 +print("substraction value - " + str(sub)) + +mul = num1 * num +print("multiplication value:-", mul) \ No newline at end of file diff --git a/Day-04/calculator_new.py b/Day-04/calculator_new.py new file mode 100644 index 00000000..dd8ef0f9 --- /dev/null +++ b/Day-04/calculator_new.py @@ -0,0 +1,24 @@ +num = 6 +num1 = 3 +num2 = -8 + +def adition(): + add = num + num1 + print(add) + +def substraction(): + sub = num - num1 + print(sub) + +def multiplication(): + mull = num1 * num + print(mull) + +def abbstraction(): + aj = abs(num2) + print(aj) + +adition() +substraction() +multiplication() +abbstraction() \ No newline at end of file diff --git a/Day-04/calling_module.py b/Day-04/calling_module.py new file mode 100644 index 00000000..213c1b22 --- /dev/null +++ b/Day-04/calling_module.py @@ -0,0 +1,24 @@ +import sys +sys.path.append('/workspaces/python-for-devops/Day-04/modules/') + + +from functions import addition + +result = addition(2, 3) + +print("the value of addition is:", result) + +from functions import substraction + +print(substraction(3, 3)) + +from functions import multiplication + +result1 = multiplication(3, 3 ) + +print("value of multiplication is - " + str(result1)) + + + + + diff --git a/Day-04/modules/functions.py b/Day-04/modules/functions.py new file mode 100644 index 00000000..024c506d --- /dev/null +++ b/Day-04/modules/functions.py @@ -0,0 +1,25 @@ +def addition(a, b): + add = a + b + return add + +def substraction(a, b): + sub = a - b + return sub + +def multiplication(a, b): + mul = a * b + return mul + +def abstraction(a): + ab = abs(a) + return ab + + +#result = abstraction(-8) +#print(" value of abstractin :", result) + +#result1 = len(str(result)) + +#print("length of o/p is:", str(result1)) + +#addition() diff --git a/Day-04/project-abc/bin/Activate.ps1 b/Day-04/project-abc/bin/Activate.ps1 new file mode 100644 index 00000000..b49d77ba --- /dev/null +++ b/Day-04/project-abc/bin/Activate.ps1 @@ -0,0 +1,247 @@ +<# +.Synopsis +Activate a Python virtual environment for the current PowerShell session. + +.Description +Pushes the python executable for a virtual environment to the front of the +$Env:PATH environment variable and sets the prompt to signify that you are +in a Python virtual environment. Makes use of the command line switches as +well as the `pyvenv.cfg` file values present in the virtual environment. + +.Parameter VenvDir +Path to the directory that contains the virtual environment to activate. The +default value for this is the parent of the directory that the Activate.ps1 +script is located within. + +.Parameter Prompt +The prompt prefix to display when this virtual environment is activated. By +default, this prompt is the name of the virtual environment folder (VenvDir) +surrounded by parentheses and followed by a single space (ie. '(.venv) '). + +.Example +Activate.ps1 +Activates the Python virtual environment that contains the Activate.ps1 script. + +.Example +Activate.ps1 -Verbose +Activates the Python virtual environment that contains the Activate.ps1 script, +and shows extra information about the activation as it executes. + +.Example +Activate.ps1 -VenvDir C:\Users\MyUser\Common\.venv +Activates the Python virtual environment located in the specified location. + +.Example +Activate.ps1 -Prompt "MyPython" +Activates the Python virtual environment that contains the Activate.ps1 script, +and prefixes the current prompt with the specified string (surrounded in +parentheses) while the virtual environment is active. + +.Notes +On Windows, it may be required to enable this Activate.ps1 script by setting the +execution policy for the user. You can do this by issuing the following PowerShell +command: + +PS C:\> Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser + +For more information on Execution Policies: +https://go.microsoft.com/fwlink/?LinkID=135170 + +#> +Param( + [Parameter(Mandatory = $false)] + [String] + $VenvDir, + [Parameter(Mandatory = $false)] + [String] + $Prompt +) + +<# Function declarations --------------------------------------------------- #> + +<# +.Synopsis +Remove all shell session elements added by the Activate script, including the +addition of the virtual environment's Python executable from the beginning of +the PATH variable. + +.Parameter NonDestructive +If present, do not remove this function from the global namespace for the +session. + +#> +function global:deactivate ([switch]$NonDestructive) { + # Revert to original values + + # The prior prompt: + if (Test-Path -Path Function:_OLD_VIRTUAL_PROMPT) { + Copy-Item -Path Function:_OLD_VIRTUAL_PROMPT -Destination Function:prompt + Remove-Item -Path Function:_OLD_VIRTUAL_PROMPT + } + + # The prior PYTHONHOME: + if (Test-Path -Path Env:_OLD_VIRTUAL_PYTHONHOME) { + Copy-Item -Path Env:_OLD_VIRTUAL_PYTHONHOME -Destination Env:PYTHONHOME + Remove-Item -Path Env:_OLD_VIRTUAL_PYTHONHOME + } + + # The prior PATH: + if (Test-Path -Path Env:_OLD_VIRTUAL_PATH) { + Copy-Item -Path Env:_OLD_VIRTUAL_PATH -Destination Env:PATH + Remove-Item -Path Env:_OLD_VIRTUAL_PATH + } + + # Just remove the VIRTUAL_ENV altogether: + if (Test-Path -Path Env:VIRTUAL_ENV) { + Remove-Item -Path env:VIRTUAL_ENV + } + + # Just remove VIRTUAL_ENV_PROMPT altogether. + if (Test-Path -Path Env:VIRTUAL_ENV_PROMPT) { + Remove-Item -Path env:VIRTUAL_ENV_PROMPT + } + + # Just remove the _PYTHON_VENV_PROMPT_PREFIX altogether: + if (Get-Variable -Name "_PYTHON_VENV_PROMPT_PREFIX" -ErrorAction SilentlyContinue) { + Remove-Variable -Name _PYTHON_VENV_PROMPT_PREFIX -Scope Global -Force + } + + # Leave deactivate function in the global namespace if requested: + if (-not $NonDestructive) { + Remove-Item -Path function:deactivate + } +} + +<# +.Description +Get-PyVenvConfig parses the values from the pyvenv.cfg file located in the +given folder, and returns them in a map. + +For each line in the pyvenv.cfg file, if that line can be parsed into exactly +two strings separated by `=` (with any amount of whitespace surrounding the =) +then it is considered a `key = value` line. The left hand string is the key, +the right hand is the value. + +If the value starts with a `'` or a `"` then the first and last character is +stripped from the value before being captured. + +.Parameter ConfigDir +Path to the directory that contains the `pyvenv.cfg` file. +#> +function Get-PyVenvConfig( + [String] + $ConfigDir +) { + Write-Verbose "Given ConfigDir=$ConfigDir, obtain values in pyvenv.cfg" + + # Ensure the file exists, and issue a warning if it doesn't (but still allow the function to continue). + $pyvenvConfigPath = Join-Path -Resolve -Path $ConfigDir -ChildPath 'pyvenv.cfg' -ErrorAction Continue + + # An empty map will be returned if no config file is found. + $pyvenvConfig = @{ } + + if ($pyvenvConfigPath) { + + Write-Verbose "File exists, parse `key = value` lines" + $pyvenvConfigContent = Get-Content -Path $pyvenvConfigPath + + $pyvenvConfigContent | ForEach-Object { + $keyval = $PSItem -split "\s*=\s*", 2 + if ($keyval[0] -and $keyval[1]) { + $val = $keyval[1] + + # Remove extraneous quotations around a string value. + if ("'""".Contains($val.Substring(0, 1))) { + $val = $val.Substring(1, $val.Length - 2) + } + + $pyvenvConfig[$keyval[0]] = $val + Write-Verbose "Adding Key: '$($keyval[0])'='$val'" + } + } + } + return $pyvenvConfig +} + + +<# Begin Activate script --------------------------------------------------- #> + +# Determine the containing directory of this script +$VenvExecPath = Split-Path -Parent $MyInvocation.MyCommand.Definition +$VenvExecDir = Get-Item -Path $VenvExecPath + +Write-Verbose "Activation script is located in path: '$VenvExecPath'" +Write-Verbose "VenvExecDir Fullname: '$($VenvExecDir.FullName)" +Write-Verbose "VenvExecDir Name: '$($VenvExecDir.Name)" + +# Set values required in priority: CmdLine, ConfigFile, Default +# First, get the location of the virtual environment, it might not be +# VenvExecDir if specified on the command line. +if ($VenvDir) { + Write-Verbose "VenvDir given as parameter, using '$VenvDir' to determine values" +} +else { + Write-Verbose "VenvDir not given as a parameter, using parent directory name as VenvDir." + $VenvDir = $VenvExecDir.Parent.FullName.TrimEnd("\\/") + Write-Verbose "VenvDir=$VenvDir" +} + +# Next, read the `pyvenv.cfg` file to determine any required value such +# as `prompt`. +$pyvenvCfg = Get-PyVenvConfig -ConfigDir $VenvDir + +# Next, set the prompt from the command line, or the config file, or +# just use the name of the virtual environment folder. +if ($Prompt) { + Write-Verbose "Prompt specified as argument, using '$Prompt'" +} +else { + Write-Verbose "Prompt not specified as argument to script, checking pyvenv.cfg value" + if ($pyvenvCfg -and $pyvenvCfg['prompt']) { + Write-Verbose " Setting based on value in pyvenv.cfg='$($pyvenvCfg['prompt'])'" + $Prompt = $pyvenvCfg['prompt']; + } + else { + Write-Verbose " Setting prompt based on parent's directory's name. (Is the directory name passed to venv module when creating the virtual environment)" + Write-Verbose " Got leaf-name of $VenvDir='$(Split-Path -Path $venvDir -Leaf)'" + $Prompt = Split-Path -Path $venvDir -Leaf + } +} + +Write-Verbose "Prompt = '$Prompt'" +Write-Verbose "VenvDir='$VenvDir'" + +# Deactivate any currently active virtual environment, but leave the +# deactivate function in place. +deactivate -nondestructive + +# Now set the environment variable VIRTUAL_ENV, used by many tools to determine +# that there is an activated venv. +$env:VIRTUAL_ENV = $VenvDir + +if (-not $Env:VIRTUAL_ENV_DISABLE_PROMPT) { + + Write-Verbose "Setting prompt to '$Prompt'" + + # Set the prompt to include the env name + # Make sure _OLD_VIRTUAL_PROMPT is global + function global:_OLD_VIRTUAL_PROMPT { "" } + Copy-Item -Path function:prompt -Destination function:_OLD_VIRTUAL_PROMPT + New-Variable -Name _PYTHON_VENV_PROMPT_PREFIX -Description "Python virtual environment prompt prefix" -Scope Global -Option ReadOnly -Visibility Public -Value $Prompt + + function global:prompt { + Write-Host -NoNewline -ForegroundColor Green "($_PYTHON_VENV_PROMPT_PREFIX) " + _OLD_VIRTUAL_PROMPT + } + $env:VIRTUAL_ENV_PROMPT = $Prompt +} + +# Clear PYTHONHOME +if (Test-Path -Path Env:PYTHONHOME) { + Copy-Item -Path Env:PYTHONHOME -Destination Env:_OLD_VIRTUAL_PYTHONHOME + Remove-Item -Path Env:PYTHONHOME +} + +# Add the venv to the PATH +Copy-Item -Path Env:PATH -Destination Env:_OLD_VIRTUAL_PATH +$Env:PATH = "$VenvExecDir$([System.IO.Path]::PathSeparator)$Env:PATH" diff --git a/Day-04/project-abc/bin/activate b/Day-04/project-abc/bin/activate new file mode 100644 index 00000000..ceed4d74 --- /dev/null +++ b/Day-04/project-abc/bin/activate @@ -0,0 +1,69 @@ +# This file must be used with "source bin/activate" *from bash* +# you cannot run it directly + +deactivate () { + # reset old environment variables + if [ -n "${_OLD_VIRTUAL_PATH:-}" ] ; then + PATH="${_OLD_VIRTUAL_PATH:-}" + export PATH + unset _OLD_VIRTUAL_PATH + fi + if [ -n "${_OLD_VIRTUAL_PYTHONHOME:-}" ] ; then + PYTHONHOME="${_OLD_VIRTUAL_PYTHONHOME:-}" + export PYTHONHOME + unset _OLD_VIRTUAL_PYTHONHOME + fi + + # This should detect bash and zsh, which have a hash command that must + # be called to get it to forget past commands. Without forgetting + # past commands the $PATH changes we made may not be respected + if [ -n "${BASH:-}" -o -n "${ZSH_VERSION:-}" ] ; then + hash -r 2> /dev/null + fi + + if [ -n "${_OLD_VIRTUAL_PS1:-}" ] ; then + PS1="${_OLD_VIRTUAL_PS1:-}" + export PS1 + unset _OLD_VIRTUAL_PS1 + fi + + unset VIRTUAL_ENV + unset VIRTUAL_ENV_PROMPT + if [ ! "${1:-}" = "nondestructive" ] ; then + # Self destruct! + unset -f deactivate + fi +} + +# unset irrelevant variables +deactivate nondestructive + +VIRTUAL_ENV="/workspaces/python-for-devops/Day-04/project-abc" +export VIRTUAL_ENV + +_OLD_VIRTUAL_PATH="$PATH" +PATH="$VIRTUAL_ENV/bin:$PATH" +export PATH + +# unset PYTHONHOME if set +# this will fail if PYTHONHOME is set to the empty string (which is bad anyway) +# could use `if (set -u; : $PYTHONHOME) ;` in bash +if [ -n "${PYTHONHOME:-}" ] ; then + _OLD_VIRTUAL_PYTHONHOME="${PYTHONHOME:-}" + unset PYTHONHOME +fi + +if [ -z "${VIRTUAL_ENV_DISABLE_PROMPT:-}" ] ; then + _OLD_VIRTUAL_PS1="${PS1:-}" + PS1="(project-abc) ${PS1:-}" + export PS1 + VIRTUAL_ENV_PROMPT="(project-abc) " + export VIRTUAL_ENV_PROMPT +fi + +# This should detect bash and zsh, which have a hash command that must +# be called to get it to forget past commands. Without forgetting +# past commands the $PATH changes we made may not be respected +if [ -n "${BASH:-}" -o -n "${ZSH_VERSION:-}" ] ; then + hash -r 2> /dev/null +fi diff --git a/Day-04/project-abc/bin/activate.csh b/Day-04/project-abc/bin/activate.csh new file mode 100644 index 00000000..784424e4 --- /dev/null +++ b/Day-04/project-abc/bin/activate.csh @@ -0,0 +1,26 @@ +# This file must be used with "source bin/activate.csh" *from csh*. +# You cannot run it directly. +# Created by Davide Di Blasi . +# Ported to Python 3.3 venv by Andrew Svetlov + +alias deactivate 'test $?_OLD_VIRTUAL_PATH != 0 && setenv PATH "$_OLD_VIRTUAL_PATH" && unset _OLD_VIRTUAL_PATH; rehash; test $?_OLD_VIRTUAL_PROMPT != 0 && set prompt="$_OLD_VIRTUAL_PROMPT" && unset _OLD_VIRTUAL_PROMPT; unsetenv VIRTUAL_ENV; unsetenv VIRTUAL_ENV_PROMPT; test "\!:*" != "nondestructive" && unalias deactivate' + +# Unset irrelevant variables. +deactivate nondestructive + +setenv VIRTUAL_ENV "/workspaces/python-for-devops/Day-04/project-abc" + +set _OLD_VIRTUAL_PATH="$PATH" +setenv PATH "$VIRTUAL_ENV/bin:$PATH" + + +set _OLD_VIRTUAL_PROMPT="$prompt" + +if (! "$?VIRTUAL_ENV_DISABLE_PROMPT") then + set prompt = "(project-abc) $prompt" + setenv VIRTUAL_ENV_PROMPT "(project-abc) " +endif + +alias pydoc python -m pydoc + +rehash diff --git a/Day-04/project-abc/bin/activate.fish b/Day-04/project-abc/bin/activate.fish new file mode 100644 index 00000000..f3600494 --- /dev/null +++ b/Day-04/project-abc/bin/activate.fish @@ -0,0 +1,69 @@ +# This file must be used with "source /bin/activate.fish" *from fish* +# (https://fishshell.com/); you cannot run it directly. + +function deactivate -d "Exit virtual environment and return to normal shell environment" + # reset old environment variables + if test -n "$_OLD_VIRTUAL_PATH" + set -gx PATH $_OLD_VIRTUAL_PATH + set -e _OLD_VIRTUAL_PATH + end + if test -n "$_OLD_VIRTUAL_PYTHONHOME" + set -gx PYTHONHOME $_OLD_VIRTUAL_PYTHONHOME + set -e _OLD_VIRTUAL_PYTHONHOME + end + + if test -n "$_OLD_FISH_PROMPT_OVERRIDE" + set -e _OLD_FISH_PROMPT_OVERRIDE + # prevents error when using nested fish instances (Issue #93858) + if functions -q _old_fish_prompt + functions -e fish_prompt + functions -c _old_fish_prompt fish_prompt + functions -e _old_fish_prompt + end + end + + set -e VIRTUAL_ENV + set -e VIRTUAL_ENV_PROMPT + if test "$argv[1]" != "nondestructive" + # Self-destruct! + functions -e deactivate + end +end + +# Unset irrelevant variables. +deactivate nondestructive + +set -gx VIRTUAL_ENV "/workspaces/python-for-devops/Day-04/project-abc" + +set -gx _OLD_VIRTUAL_PATH $PATH +set -gx PATH "$VIRTUAL_ENV/bin" $PATH + +# Unset PYTHONHOME if set. +if set -q PYTHONHOME + set -gx _OLD_VIRTUAL_PYTHONHOME $PYTHONHOME + set -e PYTHONHOME +end + +if test -z "$VIRTUAL_ENV_DISABLE_PROMPT" + # fish uses a function instead of an env var to generate the prompt. + + # Save the current fish_prompt function as the function _old_fish_prompt. + functions -c fish_prompt _old_fish_prompt + + # With the original prompt function renamed, we can override with our own. + function fish_prompt + # Save the return status of the last command. + set -l old_status $status + + # Output the venv prompt; color taken from the blue of the Python logo. + printf "%s%s%s" (set_color 4B8BBE) "(project-abc) " (set_color normal) + + # Restore the return status of the previous command. + echo "exit $old_status" | . + # Output the original/"old" prompt. + _old_fish_prompt + end + + set -gx _OLD_FISH_PROMPT_OVERRIDE "$VIRTUAL_ENV" + set -gx VIRTUAL_ENV_PROMPT "(project-abc) " +end diff --git a/Day-04/project-abc/bin/jirashell b/Day-04/project-abc/bin/jirashell new file mode 100755 index 00000000..32a05e6e --- /dev/null +++ b/Day-04/project-abc/bin/jirashell @@ -0,0 +1,8 @@ +#!/workspaces/python-for-devops/Day-04/project-abc/bin/python +# -*- coding: utf-8 -*- +import re +import sys +from jira.jirashell import main +if __name__ == '__main__': + sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) + sys.exit(main()) diff --git a/Day-04/project-abc/bin/normalizer b/Day-04/project-abc/bin/normalizer new file mode 100755 index 00000000..6e0d0c93 --- /dev/null +++ b/Day-04/project-abc/bin/normalizer @@ -0,0 +1,8 @@ +#!/workspaces/python-for-devops/Day-04/project-abc/bin/python +# -*- coding: utf-8 -*- +import re +import sys +from charset_normalizer.cli import cli_detect +if __name__ == '__main__': + sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) + sys.exit(cli_detect()) diff --git a/Day-04/project-abc/bin/pip b/Day-04/project-abc/bin/pip new file mode 100755 index 00000000..c0d096b1 --- /dev/null +++ b/Day-04/project-abc/bin/pip @@ -0,0 +1,8 @@ +#!/workspaces/python-for-devops/Day-04/project-abc/bin/python +# -*- coding: utf-8 -*- +import re +import sys +from pip._internal.cli.main import main +if __name__ == '__main__': + sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) + sys.exit(main()) diff --git a/Day-04/project-abc/bin/pip3 b/Day-04/project-abc/bin/pip3 new file mode 100755 index 00000000..c0d096b1 --- /dev/null +++ b/Day-04/project-abc/bin/pip3 @@ -0,0 +1,8 @@ +#!/workspaces/python-for-devops/Day-04/project-abc/bin/python +# -*- coding: utf-8 -*- +import re +import sys +from pip._internal.cli.main import main +if __name__ == '__main__': + sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) + sys.exit(main()) diff --git a/Day-04/project-abc/bin/pip3.10 b/Day-04/project-abc/bin/pip3.10 new file mode 100755 index 00000000..c0d096b1 --- /dev/null +++ b/Day-04/project-abc/bin/pip3.10 @@ -0,0 +1,8 @@ +#!/workspaces/python-for-devops/Day-04/project-abc/bin/python +# -*- coding: utf-8 -*- +import re +import sys +from pip._internal.cli.main import main +if __name__ == '__main__': + sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) + sys.exit(main()) diff --git a/Day-04/project-abc/bin/python b/Day-04/project-abc/bin/python new file mode 120000 index 00000000..7ae5fe3d --- /dev/null +++ b/Day-04/project-abc/bin/python @@ -0,0 +1 @@ +/home/codespace/.python/current/bin/python \ No newline at end of file diff --git a/Day-04/project-abc/bin/python3 b/Day-04/project-abc/bin/python3 new file mode 120000 index 00000000..d8654aa0 --- /dev/null +++ b/Day-04/project-abc/bin/python3 @@ -0,0 +1 @@ +python \ No newline at end of file diff --git a/Day-04/project-abc/bin/python3.10 b/Day-04/project-abc/bin/python3.10 new file mode 120000 index 00000000..d8654aa0 --- /dev/null +++ b/Day-04/project-abc/bin/python3.10 @@ -0,0 +1 @@ +python \ No newline at end of file diff --git a/Day-04/project-abc/lib64 b/Day-04/project-abc/lib64 new file mode 120000 index 00000000..7951405f --- /dev/null +++ b/Day-04/project-abc/lib64 @@ -0,0 +1 @@ +lib \ No newline at end of file diff --git a/Day-04/project-abc/pyvenv.cfg b/Day-04/project-abc/pyvenv.cfg new file mode 100644 index 00000000..f16bf74c --- /dev/null +++ b/Day-04/project-abc/pyvenv.cfg @@ -0,0 +1,3 @@ +home = /home/codespace/.python/current/bin +include-system-site-packages = false +version = 3.10.13 diff --git a/Day-04/project-xyz/bin/Activate.ps1 b/Day-04/project-xyz/bin/Activate.ps1 new file mode 100644 index 00000000..b49d77ba --- /dev/null +++ b/Day-04/project-xyz/bin/Activate.ps1 @@ -0,0 +1,247 @@ +<# +.Synopsis +Activate a Python virtual environment for the current PowerShell session. + +.Description +Pushes the python executable for a virtual environment to the front of the +$Env:PATH environment variable and sets the prompt to signify that you are +in a Python virtual environment. Makes use of the command line switches as +well as the `pyvenv.cfg` file values present in the virtual environment. + +.Parameter VenvDir +Path to the directory that contains the virtual environment to activate. The +default value for this is the parent of the directory that the Activate.ps1 +script is located within. + +.Parameter Prompt +The prompt prefix to display when this virtual environment is activated. By +default, this prompt is the name of the virtual environment folder (VenvDir) +surrounded by parentheses and followed by a single space (ie. '(.venv) '). + +.Example +Activate.ps1 +Activates the Python virtual environment that contains the Activate.ps1 script. + +.Example +Activate.ps1 -Verbose +Activates the Python virtual environment that contains the Activate.ps1 script, +and shows extra information about the activation as it executes. + +.Example +Activate.ps1 -VenvDir C:\Users\MyUser\Common\.venv +Activates the Python virtual environment located in the specified location. + +.Example +Activate.ps1 -Prompt "MyPython" +Activates the Python virtual environment that contains the Activate.ps1 script, +and prefixes the current prompt with the specified string (surrounded in +parentheses) while the virtual environment is active. + +.Notes +On Windows, it may be required to enable this Activate.ps1 script by setting the +execution policy for the user. You can do this by issuing the following PowerShell +command: + +PS C:\> Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser + +For more information on Execution Policies: +https://go.microsoft.com/fwlink/?LinkID=135170 + +#> +Param( + [Parameter(Mandatory = $false)] + [String] + $VenvDir, + [Parameter(Mandatory = $false)] + [String] + $Prompt +) + +<# Function declarations --------------------------------------------------- #> + +<# +.Synopsis +Remove all shell session elements added by the Activate script, including the +addition of the virtual environment's Python executable from the beginning of +the PATH variable. + +.Parameter NonDestructive +If present, do not remove this function from the global namespace for the +session. + +#> +function global:deactivate ([switch]$NonDestructive) { + # Revert to original values + + # The prior prompt: + if (Test-Path -Path Function:_OLD_VIRTUAL_PROMPT) { + Copy-Item -Path Function:_OLD_VIRTUAL_PROMPT -Destination Function:prompt + Remove-Item -Path Function:_OLD_VIRTUAL_PROMPT + } + + # The prior PYTHONHOME: + if (Test-Path -Path Env:_OLD_VIRTUAL_PYTHONHOME) { + Copy-Item -Path Env:_OLD_VIRTUAL_PYTHONHOME -Destination Env:PYTHONHOME + Remove-Item -Path Env:_OLD_VIRTUAL_PYTHONHOME + } + + # The prior PATH: + if (Test-Path -Path Env:_OLD_VIRTUAL_PATH) { + Copy-Item -Path Env:_OLD_VIRTUAL_PATH -Destination Env:PATH + Remove-Item -Path Env:_OLD_VIRTUAL_PATH + } + + # Just remove the VIRTUAL_ENV altogether: + if (Test-Path -Path Env:VIRTUAL_ENV) { + Remove-Item -Path env:VIRTUAL_ENV + } + + # Just remove VIRTUAL_ENV_PROMPT altogether. + if (Test-Path -Path Env:VIRTUAL_ENV_PROMPT) { + Remove-Item -Path env:VIRTUAL_ENV_PROMPT + } + + # Just remove the _PYTHON_VENV_PROMPT_PREFIX altogether: + if (Get-Variable -Name "_PYTHON_VENV_PROMPT_PREFIX" -ErrorAction SilentlyContinue) { + Remove-Variable -Name _PYTHON_VENV_PROMPT_PREFIX -Scope Global -Force + } + + # Leave deactivate function in the global namespace if requested: + if (-not $NonDestructive) { + Remove-Item -Path function:deactivate + } +} + +<# +.Description +Get-PyVenvConfig parses the values from the pyvenv.cfg file located in the +given folder, and returns them in a map. + +For each line in the pyvenv.cfg file, if that line can be parsed into exactly +two strings separated by `=` (with any amount of whitespace surrounding the =) +then it is considered a `key = value` line. The left hand string is the key, +the right hand is the value. + +If the value starts with a `'` or a `"` then the first and last character is +stripped from the value before being captured. + +.Parameter ConfigDir +Path to the directory that contains the `pyvenv.cfg` file. +#> +function Get-PyVenvConfig( + [String] + $ConfigDir +) { + Write-Verbose "Given ConfigDir=$ConfigDir, obtain values in pyvenv.cfg" + + # Ensure the file exists, and issue a warning if it doesn't (but still allow the function to continue). + $pyvenvConfigPath = Join-Path -Resolve -Path $ConfigDir -ChildPath 'pyvenv.cfg' -ErrorAction Continue + + # An empty map will be returned if no config file is found. + $pyvenvConfig = @{ } + + if ($pyvenvConfigPath) { + + Write-Verbose "File exists, parse `key = value` lines" + $pyvenvConfigContent = Get-Content -Path $pyvenvConfigPath + + $pyvenvConfigContent | ForEach-Object { + $keyval = $PSItem -split "\s*=\s*", 2 + if ($keyval[0] -and $keyval[1]) { + $val = $keyval[1] + + # Remove extraneous quotations around a string value. + if ("'""".Contains($val.Substring(0, 1))) { + $val = $val.Substring(1, $val.Length - 2) + } + + $pyvenvConfig[$keyval[0]] = $val + Write-Verbose "Adding Key: '$($keyval[0])'='$val'" + } + } + } + return $pyvenvConfig +} + + +<# Begin Activate script --------------------------------------------------- #> + +# Determine the containing directory of this script +$VenvExecPath = Split-Path -Parent $MyInvocation.MyCommand.Definition +$VenvExecDir = Get-Item -Path $VenvExecPath + +Write-Verbose "Activation script is located in path: '$VenvExecPath'" +Write-Verbose "VenvExecDir Fullname: '$($VenvExecDir.FullName)" +Write-Verbose "VenvExecDir Name: '$($VenvExecDir.Name)" + +# Set values required in priority: CmdLine, ConfigFile, Default +# First, get the location of the virtual environment, it might not be +# VenvExecDir if specified on the command line. +if ($VenvDir) { + Write-Verbose "VenvDir given as parameter, using '$VenvDir' to determine values" +} +else { + Write-Verbose "VenvDir not given as a parameter, using parent directory name as VenvDir." + $VenvDir = $VenvExecDir.Parent.FullName.TrimEnd("\\/") + Write-Verbose "VenvDir=$VenvDir" +} + +# Next, read the `pyvenv.cfg` file to determine any required value such +# as `prompt`. +$pyvenvCfg = Get-PyVenvConfig -ConfigDir $VenvDir + +# Next, set the prompt from the command line, or the config file, or +# just use the name of the virtual environment folder. +if ($Prompt) { + Write-Verbose "Prompt specified as argument, using '$Prompt'" +} +else { + Write-Verbose "Prompt not specified as argument to script, checking pyvenv.cfg value" + if ($pyvenvCfg -and $pyvenvCfg['prompt']) { + Write-Verbose " Setting based on value in pyvenv.cfg='$($pyvenvCfg['prompt'])'" + $Prompt = $pyvenvCfg['prompt']; + } + else { + Write-Verbose " Setting prompt based on parent's directory's name. (Is the directory name passed to venv module when creating the virtual environment)" + Write-Verbose " Got leaf-name of $VenvDir='$(Split-Path -Path $venvDir -Leaf)'" + $Prompt = Split-Path -Path $venvDir -Leaf + } +} + +Write-Verbose "Prompt = '$Prompt'" +Write-Verbose "VenvDir='$VenvDir'" + +# Deactivate any currently active virtual environment, but leave the +# deactivate function in place. +deactivate -nondestructive + +# Now set the environment variable VIRTUAL_ENV, used by many tools to determine +# that there is an activated venv. +$env:VIRTUAL_ENV = $VenvDir + +if (-not $Env:VIRTUAL_ENV_DISABLE_PROMPT) { + + Write-Verbose "Setting prompt to '$Prompt'" + + # Set the prompt to include the env name + # Make sure _OLD_VIRTUAL_PROMPT is global + function global:_OLD_VIRTUAL_PROMPT { "" } + Copy-Item -Path function:prompt -Destination function:_OLD_VIRTUAL_PROMPT + New-Variable -Name _PYTHON_VENV_PROMPT_PREFIX -Description "Python virtual environment prompt prefix" -Scope Global -Option ReadOnly -Visibility Public -Value $Prompt + + function global:prompt { + Write-Host -NoNewline -ForegroundColor Green "($_PYTHON_VENV_PROMPT_PREFIX) " + _OLD_VIRTUAL_PROMPT + } + $env:VIRTUAL_ENV_PROMPT = $Prompt +} + +# Clear PYTHONHOME +if (Test-Path -Path Env:PYTHONHOME) { + Copy-Item -Path Env:PYTHONHOME -Destination Env:_OLD_VIRTUAL_PYTHONHOME + Remove-Item -Path Env:PYTHONHOME +} + +# Add the venv to the PATH +Copy-Item -Path Env:PATH -Destination Env:_OLD_VIRTUAL_PATH +$Env:PATH = "$VenvExecDir$([System.IO.Path]::PathSeparator)$Env:PATH" diff --git a/Day-04/project-xyz/bin/activate b/Day-04/project-xyz/bin/activate new file mode 100644 index 00000000..d750cd93 --- /dev/null +++ b/Day-04/project-xyz/bin/activate @@ -0,0 +1,69 @@ +# This file must be used with "source bin/activate" *from bash* +# you cannot run it directly + +deactivate () { + # reset old environment variables + if [ -n "${_OLD_VIRTUAL_PATH:-}" ] ; then + PATH="${_OLD_VIRTUAL_PATH:-}" + export PATH + unset _OLD_VIRTUAL_PATH + fi + if [ -n "${_OLD_VIRTUAL_PYTHONHOME:-}" ] ; then + PYTHONHOME="${_OLD_VIRTUAL_PYTHONHOME:-}" + export PYTHONHOME + unset _OLD_VIRTUAL_PYTHONHOME + fi + + # This should detect bash and zsh, which have a hash command that must + # be called to get it to forget past commands. Without forgetting + # past commands the $PATH changes we made may not be respected + if [ -n "${BASH:-}" -o -n "${ZSH_VERSION:-}" ] ; then + hash -r 2> /dev/null + fi + + if [ -n "${_OLD_VIRTUAL_PS1:-}" ] ; then + PS1="${_OLD_VIRTUAL_PS1:-}" + export PS1 + unset _OLD_VIRTUAL_PS1 + fi + + unset VIRTUAL_ENV + unset VIRTUAL_ENV_PROMPT + if [ ! "${1:-}" = "nondestructive" ] ; then + # Self destruct! + unset -f deactivate + fi +} + +# unset irrelevant variables +deactivate nondestructive + +VIRTUAL_ENV="/workspaces/python-for-devops/Day-04/project-xyz" +export VIRTUAL_ENV + +_OLD_VIRTUAL_PATH="$PATH" +PATH="$VIRTUAL_ENV/bin:$PATH" +export PATH + +# unset PYTHONHOME if set +# this will fail if PYTHONHOME is set to the empty string (which is bad anyway) +# could use `if (set -u; : $PYTHONHOME) ;` in bash +if [ -n "${PYTHONHOME:-}" ] ; then + _OLD_VIRTUAL_PYTHONHOME="${PYTHONHOME:-}" + unset PYTHONHOME +fi + +if [ -z "${VIRTUAL_ENV_DISABLE_PROMPT:-}" ] ; then + _OLD_VIRTUAL_PS1="${PS1:-}" + PS1="(project-xyz) ${PS1:-}" + export PS1 + VIRTUAL_ENV_PROMPT="(project-xyz) " + export VIRTUAL_ENV_PROMPT +fi + +# This should detect bash and zsh, which have a hash command that must +# be called to get it to forget past commands. Without forgetting +# past commands the $PATH changes we made may not be respected +if [ -n "${BASH:-}" -o -n "${ZSH_VERSION:-}" ] ; then + hash -r 2> /dev/null +fi diff --git a/Day-04/project-xyz/bin/activate.csh b/Day-04/project-xyz/bin/activate.csh new file mode 100644 index 00000000..8bc386c0 --- /dev/null +++ b/Day-04/project-xyz/bin/activate.csh @@ -0,0 +1,26 @@ +# This file must be used with "source bin/activate.csh" *from csh*. +# You cannot run it directly. +# Created by Davide Di Blasi . +# Ported to Python 3.3 venv by Andrew Svetlov + +alias deactivate 'test $?_OLD_VIRTUAL_PATH != 0 && setenv PATH "$_OLD_VIRTUAL_PATH" && unset _OLD_VIRTUAL_PATH; rehash; test $?_OLD_VIRTUAL_PROMPT != 0 && set prompt="$_OLD_VIRTUAL_PROMPT" && unset _OLD_VIRTUAL_PROMPT; unsetenv VIRTUAL_ENV; unsetenv VIRTUAL_ENV_PROMPT; test "\!:*" != "nondestructive" && unalias deactivate' + +# Unset irrelevant variables. +deactivate nondestructive + +setenv VIRTUAL_ENV "/workspaces/python-for-devops/Day-04/project-xyz" + +set _OLD_VIRTUAL_PATH="$PATH" +setenv PATH "$VIRTUAL_ENV/bin:$PATH" + + +set _OLD_VIRTUAL_PROMPT="$prompt" + +if (! "$?VIRTUAL_ENV_DISABLE_PROMPT") then + set prompt = "(project-xyz) $prompt" + setenv VIRTUAL_ENV_PROMPT "(project-xyz) " +endif + +alias pydoc python -m pydoc + +rehash diff --git a/Day-04/project-xyz/bin/activate.fish b/Day-04/project-xyz/bin/activate.fish new file mode 100644 index 00000000..c5d762e1 --- /dev/null +++ b/Day-04/project-xyz/bin/activate.fish @@ -0,0 +1,69 @@ +# This file must be used with "source /bin/activate.fish" *from fish* +# (https://fishshell.com/); you cannot run it directly. + +function deactivate -d "Exit virtual environment and return to normal shell environment" + # reset old environment variables + if test -n "$_OLD_VIRTUAL_PATH" + set -gx PATH $_OLD_VIRTUAL_PATH + set -e _OLD_VIRTUAL_PATH + end + if test -n "$_OLD_VIRTUAL_PYTHONHOME" + set -gx PYTHONHOME $_OLD_VIRTUAL_PYTHONHOME + set -e _OLD_VIRTUAL_PYTHONHOME + end + + if test -n "$_OLD_FISH_PROMPT_OVERRIDE" + set -e _OLD_FISH_PROMPT_OVERRIDE + # prevents error when using nested fish instances (Issue #93858) + if functions -q _old_fish_prompt + functions -e fish_prompt + functions -c _old_fish_prompt fish_prompt + functions -e _old_fish_prompt + end + end + + set -e VIRTUAL_ENV + set -e VIRTUAL_ENV_PROMPT + if test "$argv[1]" != "nondestructive" + # Self-destruct! + functions -e deactivate + end +end + +# Unset irrelevant variables. +deactivate nondestructive + +set -gx VIRTUAL_ENV "/workspaces/python-for-devops/Day-04/project-xyz" + +set -gx _OLD_VIRTUAL_PATH $PATH +set -gx PATH "$VIRTUAL_ENV/bin" $PATH + +# Unset PYTHONHOME if set. +if set -q PYTHONHOME + set -gx _OLD_VIRTUAL_PYTHONHOME $PYTHONHOME + set -e PYTHONHOME +end + +if test -z "$VIRTUAL_ENV_DISABLE_PROMPT" + # fish uses a function instead of an env var to generate the prompt. + + # Save the current fish_prompt function as the function _old_fish_prompt. + functions -c fish_prompt _old_fish_prompt + + # With the original prompt function renamed, we can override with our own. + function fish_prompt + # Save the return status of the last command. + set -l old_status $status + + # Output the venv prompt; color taken from the blue of the Python logo. + printf "%s%s%s" (set_color 4B8BBE) "(project-xyz) " (set_color normal) + + # Restore the return status of the previous command. + echo "exit $old_status" | . + # Output the original/"old" prompt. + _old_fish_prompt + end + + set -gx _OLD_FISH_PROMPT_OVERRIDE "$VIRTUAL_ENV" + set -gx VIRTUAL_ENV_PROMPT "(project-xyz) " +end diff --git a/Day-04/project-xyz/bin/jirashell b/Day-04/project-xyz/bin/jirashell new file mode 100755 index 00000000..31027cd4 --- /dev/null +++ b/Day-04/project-xyz/bin/jirashell @@ -0,0 +1,8 @@ +#!/workspaces/python-for-devops/Day-04/project-xyz/bin/python +# -*- coding: utf-8 -*- +import re +import sys +from jira.jirashell import main +if __name__ == '__main__': + sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) + sys.exit(main()) diff --git a/Day-04/project-xyz/bin/keyring b/Day-04/project-xyz/bin/keyring new file mode 100755 index 00000000..6c41184c --- /dev/null +++ b/Day-04/project-xyz/bin/keyring @@ -0,0 +1,8 @@ +#!/workspaces/python-for-devops/Day-04/project-xyz/bin/python +# -*- coding: utf-8 -*- +import re +import sys +from keyring.cli import main +if __name__ == '__main__': + sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) + sys.exit(main()) diff --git a/Day-04/project-xyz/bin/normalizer b/Day-04/project-xyz/bin/normalizer new file mode 100755 index 00000000..19ab1c68 --- /dev/null +++ b/Day-04/project-xyz/bin/normalizer @@ -0,0 +1,8 @@ +#!/workspaces/python-for-devops/Day-04/project-xyz/bin/python +# -*- coding: utf-8 -*- +import re +import sys +from charset_normalizer.cli import cli_detect +if __name__ == '__main__': + sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) + sys.exit(cli_detect()) diff --git a/Day-04/project-xyz/bin/pip b/Day-04/project-xyz/bin/pip new file mode 100755 index 00000000..fef93719 --- /dev/null +++ b/Day-04/project-xyz/bin/pip @@ -0,0 +1,8 @@ +#!/workspaces/python-for-devops/Day-04/project-xyz/bin/python +# -*- coding: utf-8 -*- +import re +import sys +from pip._internal.cli.main import main +if __name__ == '__main__': + sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) + sys.exit(main()) diff --git a/Day-04/project-xyz/bin/pip3 b/Day-04/project-xyz/bin/pip3 new file mode 100755 index 00000000..fef93719 --- /dev/null +++ b/Day-04/project-xyz/bin/pip3 @@ -0,0 +1,8 @@ +#!/workspaces/python-for-devops/Day-04/project-xyz/bin/python +# -*- coding: utf-8 -*- +import re +import sys +from pip._internal.cli.main import main +if __name__ == '__main__': + sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) + sys.exit(main()) diff --git a/Day-04/project-xyz/bin/pip3.10 b/Day-04/project-xyz/bin/pip3.10 new file mode 100755 index 00000000..fef93719 --- /dev/null +++ b/Day-04/project-xyz/bin/pip3.10 @@ -0,0 +1,8 @@ +#!/workspaces/python-for-devops/Day-04/project-xyz/bin/python +# -*- coding: utf-8 -*- +import re +import sys +from pip._internal.cli.main import main +if __name__ == '__main__': + sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) + sys.exit(main()) diff --git a/Day-04/project-xyz/bin/python b/Day-04/project-xyz/bin/python new file mode 120000 index 00000000..7ae5fe3d --- /dev/null +++ b/Day-04/project-xyz/bin/python @@ -0,0 +1 @@ +/home/codespace/.python/current/bin/python \ No newline at end of file diff --git a/Day-04/project-xyz/bin/python3 b/Day-04/project-xyz/bin/python3 new file mode 120000 index 00000000..d8654aa0 --- /dev/null +++ b/Day-04/project-xyz/bin/python3 @@ -0,0 +1 @@ +python \ No newline at end of file diff --git a/Day-04/project-xyz/bin/python3.10 b/Day-04/project-xyz/bin/python3.10 new file mode 120000 index 00000000..d8654aa0 --- /dev/null +++ b/Day-04/project-xyz/bin/python3.10 @@ -0,0 +1 @@ +python \ No newline at end of file diff --git a/Day-04/project-xyz/lib64 b/Day-04/project-xyz/lib64 new file mode 120000 index 00000000..7951405f --- /dev/null +++ b/Day-04/project-xyz/lib64 @@ -0,0 +1 @@ +lib \ No newline at end of file diff --git a/Day-04/project-xyz/pyvenv.cfg b/Day-04/project-xyz/pyvenv.cfg new file mode 100644 index 00000000..f16bf74c --- /dev/null +++ b/Day-04/project-xyz/pyvenv.cfg @@ -0,0 +1,3 @@ +home = /home/codespace/.python/current/bin +include-system-site-packages = false +version = 3.10.13