From f6d783db160321a1fe1dfea808ed91070abcfc73 Mon Sep 17 00:00:00 2001 From: Basant Kumar Mohanty Date: Fri, 29 Mar 2024 10:33:19 +0000 Subject: [PATCH 01/16] dgf --- hello.py | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 hello.py diff --git a/hello.py b/hello.py new file mode 100644 index 00000000..790c0339 --- /dev/null +++ b/hello.py @@ -0,0 +1,2 @@ +a = ['abc', 'data', 'sam'] +print("a") \ No newline at end of file From 85040f8514e5fa0ea2b87a494a4f3f8d36d109c6 Mon Sep 17 00:00:00 2001 From: Basant Kumar Mohanty Date: Fri, 29 Mar 2024 10:40:27 +0000 Subject: [PATCH 02/16] update --- hello.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/hello.py b/hello.py index 790c0339..5b863b13 100644 --- a/hello.py +++ b/hello.py @@ -1,2 +1,9 @@ -a = ['abc', 'data', 'sam'] -print("a") \ No newline at end of file +server_name = "my_server" +port = 80 +is_https_enabled = True +max_connections = 1000 + +print(f"Server Name: {Web}") +print(f"Port: {80}") +print(f"HTTPS Enabled: {True}") +print(f"Max Connections: {1000}") \ No newline at end of file From bd9d51d2b2ae5b4c54d519036d71e4e7b14f6849 Mon Sep 17 00:00:00 2001 From: basantgit Date: Fri, 29 Mar 2024 15:53:33 +0000 Subject: [PATCH 03/16] updated one --- hello.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hello.py b/hello.py index 5b863b13..ee9618ec 100644 --- a/hello.py +++ b/hello.py @@ -3,7 +3,7 @@ is_https_enabled = True max_connections = 1000 -print(f"Server Name: {Web}") +print(f"Server Name: {my_server}") print(f"Port: {80}") print(f"HTTPS Enabled: {True}") print(f"Max Connections: {1000}") \ No newline at end of file From ef1622ee1fededc1940a952d380bca3a4361d7e7 Mon Sep 17 00:00:00 2001 From: basantgit Date: Fri, 29 Mar 2024 16:10:37 +0000 Subject: [PATCH 04/16] New file addd --- first.py | 1 + 1 file changed, 1 insertion(+) create mode 100644 first.py diff --git a/first.py b/first.py new file mode 100644 index 00000000..6d95fe97 --- /dev/null +++ b/first.py @@ -0,0 +1 @@ +print("Hello world") \ No newline at end of file From b905b8f6b3110b7f33ffe548d8f93361267ac34e Mon Sep 17 00:00:00 2001 From: Basant Kumar Mohanty Date: Sat, 30 Mar 2024 10:22:08 +0000 Subject: [PATCH 05/16] updated --- first.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/first.py b/first.py index 6d95fe97..ef02be9f 100644 --- a/first.py +++ b/first.py @@ -1 +1,2 @@ -print("Hello world") \ No newline at end of file +print("Hello world") +print("hello india") \ No newline at end of file From 9a410d17d7172bfa9aab6be635a7da8582cbc013 Mon Sep 17 00:00:00 2001 From: Basant Kumar Mohanty Date: Sun, 31 Mar 2024 16:23:03 +0530 Subject: [PATCH 06/16] Update README.md --- Day-05/README.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Day-05/README.md b/Day-05/README.md index e69de29b..4396fa45 100644 --- a/Day-05/README.md +++ b/Day-05/README.md @@ -0,0 +1,7 @@ +Day 5: Environment Variables and Command Line Arguments +Reading and writing environment variables in Python. +Using the os and dotenv modules. +Securing sensitive information in environment variables. +Handling command line arguments in Python. +Practice exercises and examples: +Example: Developing a Python script that accepts command line arguments to customize DevOps automation tasks. From 341d1e1373a7550eced5dc903690b16f7cbd4019 Mon Sep 17 00:00:00 2001 From: Basant Kumar Mohanty Date: Tue, 2 Apr 2024 06:14:53 +0000 Subject: [PATCH 07/16] updated --- Day-10/def.py | 24 ++++++++++++++++++++++++ Day-10/firstproject.py | 13 +++++++++++++ Day-10/forloop.py | 3 +++ Day-10/whileloop/while.py | 13 +++++++++++++ 4 files changed, 53 insertions(+) create mode 100644 Day-10/def.py create mode 100644 Day-10/firstproject.py create mode 100644 Day-10/forloop.py create mode 100644 Day-10/whileloop/while.py diff --git a/Day-10/def.py b/Day-10/def.py new file mode 100644 index 00000000..c9e13957 --- /dev/null +++ b/Day-10/def.py @@ -0,0 +1,24 @@ +import os + +def list_file_in_folder(folder_path): + try: + files = os.listdir(folder_path) + return files, None + except FileNotFoundError: + return None, 'folder not found' + except PermissionError: + return None, 'Dont have much permissions for acces the folder' + +def main(): + folder_paths = input("Please enter folder name with the space: ").split() + for folder_path in folder_paths: + files, error_messages = list_file_in_folder(folder_path) + if files: + print(f"files in {folder_path}") + for file in files: + print(file) + else: + print(f"error in {folder_path}: {error_messages}") + +if __name__ == "__main__": + main() diff --git a/Day-10/firstproject.py b/Day-10/firstproject.py new file mode 100644 index 00000000..0dea42d3 --- /dev/null +++ b/Day-10/firstproject.py @@ -0,0 +1,13 @@ +import os + +folders = input("Please enter folder name with the space: ").split() + +for folder in folders: + try: + files = os.listdir(folder) + except FileNotFoundError: + print("please enter a valide folder name: ") + break + print(" ===== files in the foler - " + folder) + for file in files: + print(file) diff --git a/Day-10/forloop.py b/Day-10/forloop.py new file mode 100644 index 00000000..c698922d --- /dev/null +++ b/Day-10/forloop.py @@ -0,0 +1,3 @@ +cars = ["bmw", "honda"] +for i in range(10): + print(i) \ No newline at end of file diff --git a/Day-10/whileloop/while.py b/Day-10/whileloop/while.py new file mode 100644 index 00000000..f5575aa5 --- /dev/null +++ b/Day-10/whileloop/while.py @@ -0,0 +1,13 @@ +# i = 1 +# while i < 6: +# print(i) +# if i == 3: +# break +# i += 1 + +i = 0 +while i < 6: + i += 1 + if i == 3: + continue + print(i) \ No newline at end of file From 1b648d165520ab0369c669a1e82da2f4ff7e82a0 Mon Sep 17 00:00:00 2001 From: Basant Kumar Mohanty Date: Sat, 13 Apr 2024 23:09:01 +0000 Subject: [PATCH 08/16] updated --- Day-04/cal.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 Day-04/cal.py diff --git a/Day-04/cal.py b/Day-04/cal.py new file mode 100644 index 00000000..d9246bed --- /dev/null +++ b/Day-04/cal.py @@ -0,0 +1,18 @@ +num1 = 10 +num2 = 20 + +def addition(): + add = num1 + num2 + print(add) + +def sub(): + s = num1 - num2 + print(s) + +def mul(): + m = num1 * num2 + print(m) + +addition() +sub() +mul() \ No newline at end of file From b7f9a16611a5b337276b4ad0014f28ee884c8f93 Mon Sep 17 00:00:00 2001 From: Basant Kumar Mohanty Date: Sat, 13 Apr 2024 23:27:56 +0000 Subject: [PATCH 09/16] commited function --- Day-04/cal_new.py | 3 +++ Day-04/fun.py | 15 +++++++++++++++ 2 files changed, 18 insertions(+) create mode 100644 Day-04/cal_new.py create mode 100644 Day-04/fun.py diff --git a/Day-04/cal_new.py b/Day-04/cal_new.py new file mode 100644 index 00000000..dcb812bd --- /dev/null +++ b/Day-04/cal_new.py @@ -0,0 +1,3 @@ +import cal as cal_new + +cal_new diff --git a/Day-04/fun.py b/Day-04/fun.py new file mode 100644 index 00000000..63f8a711 --- /dev/null +++ b/Day-04/fun.py @@ -0,0 +1,15 @@ +def addition(num1, num2): + add = num1 + num2 + return add + +def sub(num1, num2): + s = num1 - num2 + return s + +def mul(num1, num2): + m = num1 * num2 + return m + +print (addition(10, 10)) +print (sub(10, 10)) +print (mul(10, 10)) \ No newline at end of file From 8a092426e6ece4f386ddc8edec1b14bf3766edee Mon Sep 17 00:00:00 2001 From: Basant Kumar Mohanty Date: Sun, 14 Apr 2024 00:32:32 +0000 Subject: [PATCH 10/16] Added workspace venv --- Day-04/packages.py | 4 + project-abc/bin/Activate.ps1 | 247 ++++++++++++++++++++++++++++++++++ project-abc/bin/activate | 70 ++++++++++ project-abc/bin/activate.csh | 27 ++++ project-abc/bin/activate.fish | 69 ++++++++++ project-abc/bin/jirashell | 8 ++ project-abc/bin/normalizer | 8 ++ project-abc/bin/pip | 8 ++ project-abc/bin/pip3 | 8 ++ project-abc/bin/pip3.12 | 8 ++ project-abc/bin/python | 1 + project-abc/bin/python3 | 1 + project-abc/bin/python3.12 | 1 + project-abc/lib64 | 1 + project-abc/pyvenv.cfg | 5 + project-new/bin/Activate.ps1 | 247 ++++++++++++++++++++++++++++++++++ project-new/bin/activate | 70 ++++++++++ project-new/bin/activate.csh | 27 ++++ project-new/bin/activate.fish | 69 ++++++++++ project-new/bin/jirashell | 8 ++ project-new/bin/normalizer | 8 ++ project-new/bin/pip | 8 ++ project-new/bin/pip3 | 8 ++ project-new/bin/pip3.12 | 8 ++ project-new/bin/python | 1 + project-new/bin/python3 | 1 + project-new/bin/python3.12 | 1 + project-new/lib64 | 1 + project-new/pyvenv.cfg | 5 + 29 files changed, 928 insertions(+) create mode 100644 Day-04/packages.py create mode 100644 project-abc/bin/Activate.ps1 create mode 100644 project-abc/bin/activate create mode 100644 project-abc/bin/activate.csh create mode 100644 project-abc/bin/activate.fish create mode 100755 project-abc/bin/jirashell create mode 100755 project-abc/bin/normalizer create mode 100755 project-abc/bin/pip create mode 100755 project-abc/bin/pip3 create mode 100755 project-abc/bin/pip3.12 create mode 120000 project-abc/bin/python create mode 120000 project-abc/bin/python3 create mode 120000 project-abc/bin/python3.12 create mode 120000 project-abc/lib64 create mode 100644 project-abc/pyvenv.cfg create mode 100644 project-new/bin/Activate.ps1 create mode 100644 project-new/bin/activate create mode 100644 project-new/bin/activate.csh create mode 100644 project-new/bin/activate.fish create mode 100755 project-new/bin/jirashell create mode 100755 project-new/bin/normalizer create mode 100755 project-new/bin/pip create mode 100755 project-new/bin/pip3 create mode 100755 project-new/bin/pip3.12 create mode 120000 project-new/bin/python create mode 120000 project-new/bin/python3 create mode 120000 project-new/bin/python3.12 create mode 120000 project-new/lib64 create mode 100644 project-new/pyvenv.cfg diff --git a/Day-04/packages.py b/Day-04/packages.py new file mode 100644 index 00000000..721bd030 --- /dev/null +++ b/Day-04/packages.py @@ -0,0 +1,4 @@ +pip install virtualenv --- #Create virtualenv +python -m venv project-abc # Create workspace of projecet-abc name +source project-abc/bin/ativate #Sclect projet and go inside it +deactivate # Exit form workspace project \ No newline at end of file diff --git a/project-abc/bin/Activate.ps1 b/project-abc/bin/Activate.ps1 new file mode 100644 index 00000000..b49d77ba --- /dev/null +++ b/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/project-abc/bin/activate b/project-abc/bin/activate new file mode 100644 index 00000000..ddcbece8 --- /dev/null +++ b/project-abc/bin/activate @@ -0,0 +1,70 @@ +# 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 + + # Call hash to forget past commands. Without forgetting + # past commands the $PATH changes we made may not be respected + hash -r 2> /dev/null + + 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 + +# on Windows, a path can contain colons and backslashes and has to be converted: +if [ "${OSTYPE:-}" = "cygwin" ] || [ "${OSTYPE:-}" = "msys" ] ; then + # transform D:\path\to\venv to /d/path/to/venv on MSYS + # and to /cygdrive/d/path/to/venv on Cygwin + export VIRTUAL_ENV=$(cygpath "/workspace/Python/project-abc") +else + # use the path as-is + export VIRTUAL_ENV="/workspace/Python/project-abc" +fi + +_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 + +# Call hash to forget past commands. Without forgetting +# past commands the $PATH changes we made may not be respected +hash -r 2> /dev/null diff --git a/project-abc/bin/activate.csh b/project-abc/bin/activate.csh new file mode 100644 index 00000000..3e6cf34d --- /dev/null +++ b/project-abc/bin/activate.csh @@ -0,0 +1,27 @@ +# 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 "/workspace/Python/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/project-abc/bin/activate.fish b/project-abc/bin/activate.fish new file mode 100644 index 00000000..5a9948fc --- /dev/null +++ b/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 "/workspace/Python/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/project-abc/bin/jirashell b/project-abc/bin/jirashell new file mode 100755 index 00000000..a0f87c0c --- /dev/null +++ b/project-abc/bin/jirashell @@ -0,0 +1,8 @@ +#!/workspace/Python/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/project-abc/bin/normalizer b/project-abc/bin/normalizer new file mode 100755 index 00000000..b879f891 --- /dev/null +++ b/project-abc/bin/normalizer @@ -0,0 +1,8 @@ +#!/workspace/Python/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/project-abc/bin/pip b/project-abc/bin/pip new file mode 100755 index 00000000..43456136 --- /dev/null +++ b/project-abc/bin/pip @@ -0,0 +1,8 @@ +#!/workspace/Python/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/project-abc/bin/pip3 b/project-abc/bin/pip3 new file mode 100755 index 00000000..43456136 --- /dev/null +++ b/project-abc/bin/pip3 @@ -0,0 +1,8 @@ +#!/workspace/Python/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/project-abc/bin/pip3.12 b/project-abc/bin/pip3.12 new file mode 100755 index 00000000..43456136 --- /dev/null +++ b/project-abc/bin/pip3.12 @@ -0,0 +1,8 @@ +#!/workspace/Python/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/project-abc/bin/python b/project-abc/bin/python new file mode 120000 index 00000000..69076529 --- /dev/null +++ b/project-abc/bin/python @@ -0,0 +1 @@ +/home/gitpod/.pyenv/versions/3.12.2/bin/python \ No newline at end of file diff --git a/project-abc/bin/python3 b/project-abc/bin/python3 new file mode 120000 index 00000000..d8654aa0 --- /dev/null +++ b/project-abc/bin/python3 @@ -0,0 +1 @@ +python \ No newline at end of file diff --git a/project-abc/bin/python3.12 b/project-abc/bin/python3.12 new file mode 120000 index 00000000..d8654aa0 --- /dev/null +++ b/project-abc/bin/python3.12 @@ -0,0 +1 @@ +python \ No newline at end of file diff --git a/project-abc/lib64 b/project-abc/lib64 new file mode 120000 index 00000000..7951405f --- /dev/null +++ b/project-abc/lib64 @@ -0,0 +1 @@ +lib \ No newline at end of file diff --git a/project-abc/pyvenv.cfg b/project-abc/pyvenv.cfg new file mode 100644 index 00000000..4e3f1fdd --- /dev/null +++ b/project-abc/pyvenv.cfg @@ -0,0 +1,5 @@ +home = /home/gitpod/.pyenv/versions/3.12.2/bin +include-system-site-packages = false +version = 3.12.2 +executable = /home/gitpod/.pyenv/versions/3.12.2/bin/python3.12 +command = /home/gitpod/.pyenv/versions/3.12.2/bin/python -m venv /workspace/Python/project-abc diff --git a/project-new/bin/Activate.ps1 b/project-new/bin/Activate.ps1 new file mode 100644 index 00000000..b49d77ba --- /dev/null +++ b/project-new/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/project-new/bin/activate b/project-new/bin/activate new file mode 100644 index 00000000..d8b9a053 --- /dev/null +++ b/project-new/bin/activate @@ -0,0 +1,70 @@ +# 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 + + # Call hash to forget past commands. Without forgetting + # past commands the $PATH changes we made may not be respected + hash -r 2> /dev/null + + 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 + +# on Windows, a path can contain colons and backslashes and has to be converted: +if [ "${OSTYPE:-}" = "cygwin" ] || [ "${OSTYPE:-}" = "msys" ] ; then + # transform D:\path\to\venv to /d/path/to/venv on MSYS + # and to /cygdrive/d/path/to/venv on Cygwin + export VIRTUAL_ENV=$(cygpath "/workspace/Python/project-new") +else + # use the path as-is + export VIRTUAL_ENV="/workspace/Python/project-new" +fi + +_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-new) ${PS1:-}" + export PS1 + VIRTUAL_ENV_PROMPT="(project-new) " + export VIRTUAL_ENV_PROMPT +fi + +# Call hash to forget past commands. Without forgetting +# past commands the $PATH changes we made may not be respected +hash -r 2> /dev/null diff --git a/project-new/bin/activate.csh b/project-new/bin/activate.csh new file mode 100644 index 00000000..0536e0b5 --- /dev/null +++ b/project-new/bin/activate.csh @@ -0,0 +1,27 @@ +# 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 "/workspace/Python/project-new" + +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-new) $prompt" + setenv VIRTUAL_ENV_PROMPT "(project-new) " +endif + +alias pydoc python -m pydoc + +rehash diff --git a/project-new/bin/activate.fish b/project-new/bin/activate.fish new file mode 100644 index 00000000..3777ebaa --- /dev/null +++ b/project-new/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 "/workspace/Python/project-new" + +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-new) " (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-new) " +end diff --git a/project-new/bin/jirashell b/project-new/bin/jirashell new file mode 100755 index 00000000..8f3c0110 --- /dev/null +++ b/project-new/bin/jirashell @@ -0,0 +1,8 @@ +#!/workspace/Python/project-new/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/project-new/bin/normalizer b/project-new/bin/normalizer new file mode 100755 index 00000000..7334880a --- /dev/null +++ b/project-new/bin/normalizer @@ -0,0 +1,8 @@ +#!/workspace/Python/project-new/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/project-new/bin/pip b/project-new/bin/pip new file mode 100755 index 00000000..b1fe3983 --- /dev/null +++ b/project-new/bin/pip @@ -0,0 +1,8 @@ +#!/workspace/Python/project-new/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/project-new/bin/pip3 b/project-new/bin/pip3 new file mode 100755 index 00000000..b1fe3983 --- /dev/null +++ b/project-new/bin/pip3 @@ -0,0 +1,8 @@ +#!/workspace/Python/project-new/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/project-new/bin/pip3.12 b/project-new/bin/pip3.12 new file mode 100755 index 00000000..b1fe3983 --- /dev/null +++ b/project-new/bin/pip3.12 @@ -0,0 +1,8 @@ +#!/workspace/Python/project-new/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/project-new/bin/python b/project-new/bin/python new file mode 120000 index 00000000..69076529 --- /dev/null +++ b/project-new/bin/python @@ -0,0 +1 @@ +/home/gitpod/.pyenv/versions/3.12.2/bin/python \ No newline at end of file diff --git a/project-new/bin/python3 b/project-new/bin/python3 new file mode 120000 index 00000000..d8654aa0 --- /dev/null +++ b/project-new/bin/python3 @@ -0,0 +1 @@ +python \ No newline at end of file diff --git a/project-new/bin/python3.12 b/project-new/bin/python3.12 new file mode 120000 index 00000000..d8654aa0 --- /dev/null +++ b/project-new/bin/python3.12 @@ -0,0 +1 @@ +python \ No newline at end of file diff --git a/project-new/lib64 b/project-new/lib64 new file mode 120000 index 00000000..7951405f --- /dev/null +++ b/project-new/lib64 @@ -0,0 +1 @@ +lib \ No newline at end of file diff --git a/project-new/pyvenv.cfg b/project-new/pyvenv.cfg new file mode 100644 index 00000000..5ccee5f5 --- /dev/null +++ b/project-new/pyvenv.cfg @@ -0,0 +1,5 @@ +home = /home/gitpod/.pyenv/versions/3.12.2/bin +include-system-site-packages = false +version = 3.12.2 +executable = /home/gitpod/.pyenv/versions/3.12.2/bin/python3.12 +command = /home/gitpod/.pyenv/versions/3.12.2/bin/python -m venv /workspace/Python/project-new From 8510c455c800b1600abea8ae4f556783b003a937 Mon Sep 17 00:00:00 2001 From: Basant Kumar Mohanty Date: Fri, 19 Apr 2024 08:32:52 +0000 Subject: [PATCH 11/16] updated --- first.py | 15 +++++++++++++-- gitrepo.py | 7 +++++++ 2 files changed, 20 insertions(+), 2 deletions(-) create mode 100644 gitrepo.py diff --git a/first.py b/first.py index ef02be9f..7857e8a3 100644 --- a/first.py +++ b/first.py @@ -1,2 +1,13 @@ -print("Hello world") -print("hello india") \ No newline at end of file +import os + +name = input("Please enter folder name with space: ").split() +for i in name: + try: + files = os.listdir(i) + except FileNotFoundError: + print("Please enter valid folder name") + break + except PermissionError: + print("User don't have enough permissions to excute the program") + for file in files: + print(file) \ No newline at end of file diff --git a/gitrepo.py b/gitrepo.py new file mode 100644 index 00000000..326524bf --- /dev/null +++ b/gitrepo.py @@ -0,0 +1,7 @@ +import requests + +respons = requests.get("https://api.github.com/repos/kubernetes/kubernetes/pulls") + +details = respons.json() + +print(details[2] ["user"] ["url"]) \ No newline at end of file From 1970fb171b011c16056fc199786e5e2b6d57a6ba Mon Sep 17 00:00:00 2001 From: Basant Kumar Mohanty Date: Sat, 20 Apr 2024 13:42:45 +0000 Subject: [PATCH 12/16] file operations in python --- Day-12/file.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 Day-12/file.py diff --git a/Day-12/file.py b/Day-12/file.py new file mode 100644 index 00000000..d432ca92 --- /dev/null +++ b/Day-12/file.py @@ -0,0 +1,25 @@ +def update_server_config(file_path, key, value): + + with open(file_path, "r") as file: + + lines = file.readlines() + + with open(file_path, "w") as file: + + for line in lines: + + if key in line: + file.write(key + "=" + value + "\n") + else: + file.write(line) + +# Path to the server configuration file +server_config_file = 'server.conf' + +# Key and new value for updating the server configuration +key_to_update = 'MAX_CONNECTIONS' +new_value = '600' # New maximum connections allowed + +# Update the server configuration file +update_server_config(server_config_file, key_to_update, new_value) + From 92339fb83366cf5d2fa1cd1b87adc7d8e3440c92 Mon Sep 17 00:00:00 2001 From: Basant Kumar Mohanty Date: Sun, 21 Apr 2024 13:46:22 +0000 Subject: [PATCH 13/16] updated --- data_type.py | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 data_type.py diff --git a/data_type.py b/data_type.py new file mode 100644 index 00000000..e3657a41 --- /dev/null +++ b/data_type.py @@ -0,0 +1,38 @@ +# # # name = "basant" # variable use for +# # # age = 35 +# # # point = 2.9 + +# # # print (type(name)) +# # # print (type(age)) +# # # print (type(point)) + +# # # ''' variable use for +# # # hello this is comments +# # # ''' + +# # # name = "Basant Mohanty" +# # # print(name[0:12]) + +# # name = "I am studying am python" +# # print(name.count("am")) +# # txt = 'i 36 is my age.' + +# # x = txt.capitalize() + +# # print (x) +# name = input("Please enter your name: ") +# print("Lenth is your name:", len(name)) + + + + + + + + + + + + + + From 8338a21e7d69fa32d251b40674d96c01aaa63580 Mon Sep 17 00:00:00 2001 From: Basant Kumar Mohanty Date: Mon, 22 Apr 2024 19:57:40 +0530 Subject: [PATCH 14/16] Create python-package-conda.yml --- .github/workflows/python-package-conda.yml | 34 ++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 .github/workflows/python-package-conda.yml diff --git a/.github/workflows/python-package-conda.yml b/.github/workflows/python-package-conda.yml new file mode 100644 index 00000000..384f9b72 --- /dev/null +++ b/.github/workflows/python-package-conda.yml @@ -0,0 +1,34 @@ +name: Python Package using Conda + +on: [push] + +jobs: + build-linux: + runs-on: ubuntu-latest + strategy: + max-parallel: 5 + + steps: + - uses: actions/checkout@v3 + - name: Set up Python 3.10 + uses: actions/setup-python@v3 + with: + python-version: '3.10' + - name: Add conda to system path + run: | + # $CONDA is an environment variable pointing to the root of the miniconda directory + echo $CONDA/bin >> $GITHUB_PATH + - name: Install dependencies + run: | + conda env update --file environment.yml --name base + - name: Lint with flake8 + run: | + conda install flake8 + # stop the build if there are Python syntax errors or undefined names + flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics + # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide + flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics + - name: Test with pytest + run: | + conda install pytest + pytest From be52d3bc12be7b92343c73c4953477e952e4ffb9 Mon Sep 17 00:00:00 2001 From: Basant Kumar Mohanty Date: Thu, 25 Apr 2024 15:33:32 +0000 Subject: [PATCH 15/16] updated --- data_type.py | 42 ++++++++++++++++++++---------------------- dict.py | 44 ++++++++++++++++++++++++++++++++++++++++++++ loops.py | 11 +++++++++++ 3 files changed, 75 insertions(+), 22 deletions(-) create mode 100644 dict.py create mode 100644 loops.py diff --git a/data_type.py b/data_type.py index e3657a41..10e68979 100644 --- a/data_type.py +++ b/data_type.py @@ -1,32 +1,30 @@ -# # # name = "basant" # variable use for -# # # age = 35 -# # # point = 2.9 +# # # # name = "basant" # variable use for +# # # # age = 35 +# # # # point = 2.9 -# # # print (type(name)) -# # # print (type(age)) -# # # print (type(point)) +# # # # print (type(name)) +# # # # print (type(age)) +# # # # print (type(point)) -# # # ''' variable use for -# # # hello this is comments -# # # ''' - -# # # name = "Basant Mohanty" -# # # print(name[0:12]) - -# # name = "I am studying am python" -# # print(name.count("am")) -# # txt = 'i 36 is my age.' - -# # x = txt.capitalize() - -# # print (x) -# name = input("Please enter your name: ") -# print("Lenth is your name:", len(name)) +# # # # ''' variable use for +# # # # hello this is comments +# # # # ''' +# # # # name = "Basant Mohanty" +# # # # print(name[0:12]) +# # # name = "I am studying am python" +# # # print(name.count("am")) +# # # txt = 'i 36 is my age.' +# # # x = txt.capitalize() +# # # print (x) +# # name = input("Please enter your name: ") +# # print("Lenth is your name:", len(name)) +# hello = {1, 2, 3} +# print(type(hello)) diff --git a/dict.py b/dict.py new file mode 100644 index 00000000..6756bfc8 --- /dev/null +++ b/dict.py @@ -0,0 +1,44 @@ +# # _________________________________________________ +# # dict = { +# # "name" : "basant", +# # "age" : 26, +# # "story" : ["thebook", "waytogo"] +# # } +# # dict['age'] = 30 +# # print(dict["story"]) +# #---------------------------------------------------------- +# # student = { +# # "name" : "Basant Kumar Mohanty", +# # "subject" : { +# # "math" : 80, +# # "mil" : 65, +# # "English" : 75 + +# # } +# # } + +# # # print(student["subject"]["math"]) +# # # print(student.keys()) +# # # print(len(list(student.values()))) +# # # print(student.get["subject"]) +# # print(car = { +# # 'brand': 'Ford', +# # 'model': 'Mustang', +# # 'year': 1964 +# # }) +# # x = car.get('price', 15000) +# # print(x) +# # # __________________________________________________________ + +# # collection = {1, 2, 2, 2, 3, 4, "hello", "hello"} +# # print(collection) +# # print(type(collection)) +# # print(len(collection)) + +# collection = {"Basant", "Mohanty", "Odish"} +# collection.pop() +# # print(collection) +# set1 = {1, 2, 3,} +# set2 = {2, 3, 4,} +# print(set1.union(set2)) +# print(set1.intersection(set2)) diff --git a/loops.py b/loops.py new file mode 100644 index 00000000..c3799d5d --- /dev/null +++ b/loops.py @@ -0,0 +1,11 @@ +# i = 1 +# while i <= 20: +# if(i%2 == 0): +# i += 1 +# continue + +# print(i) +# i += 1 +# # end while +for i in range(2, 100, 2): + print(i) \ No newline at end of file From dc7e8cf835f49564e27a108544113fd591f1cffd Mon Sep 17 00:00:00 2001 From: Basant Kumar Mohanty Date: Fri, 26 Apr 2024 13:20:00 +0000 Subject: [PATCH 16/16] added new script --- file_io.py | 26 ++++++++++++++++++++++++++ filename.txt | 2 ++ func.py | 4 ++++ pyfile.txt | 3 +++ 4 files changed, 35 insertions(+) create mode 100644 file_io.py create mode 100644 filename.txt create mode 100644 func.py create mode 100644 pyfile.txt diff --git a/file_io.py b/file_io.py new file mode 100644 index 00000000..399b080a --- /dev/null +++ b/file_io.py @@ -0,0 +1,26 @@ +# import os + +# with open("pyfile.txt", "a") as f: +# file = f.write("My name is") +# print(file) +# f.close() + +# with open("filename.txt", "w") as f: +# f.write("This is basant, \nI am from Odissa") +# f.write("I am learning python") +# with open("filename.txt", "r") as f: +# data = f.read() +# new_data = data.replace("python", "JAVA") +# print(new_data) + +# with open("filename.txt", "w") as f: +# f.write(new_data) +def file_op_sc(): + word = "gLearning" + with open("filename.txt", "r") as f: + data = f.read() + if(data.find(word) != -1): + print("word Found") + else: + print("word not found") +file_op_sc() \ No newline at end of file diff --git a/filename.txt b/filename.txt new file mode 100644 index 00000000..010f124b --- /dev/null +++ b/filename.txt @@ -0,0 +1,2 @@ +This is basant, +I am from OdissaI am Learning JAVA \ No newline at end of file diff --git a/func.py b/func.py new file mode 100644 index 00000000..8d54bc41 --- /dev/null +++ b/func.py @@ -0,0 +1,4 @@ +def name(a, b): + return a + b +sum = name(1, 4) +print(sum) diff --git a/pyfile.txt b/pyfile.txt new file mode 100644 index 00000000..591866e9 --- /dev/null +++ b/pyfile.txt @@ -0,0 +1,3 @@ + +My name is basants book name is MILMy name is basant +My name is basantMy name is \ No newline at end of file