Recognizing macOS Platform
See original GitHub issueThe code that determines the platform (in _utility.platform.py
) doesn’t work for macOS, and it doesn’t work for most flavors of Unix:
def platform(): # the platform (eg: linux) you are using plotext with
platform = sys.platform
names = ["win", "linux", "unix"]
platforms = ["windows", "linux", "unix"]
for i in range(3):
if names[i] in platform:
return platforms[i]
return "not found"
On macOS, platform
is "darwin"
, which contains "win"
and therefore gets labeled “windows”.
I recommend rewriting that function to:
def platform(): # the platform (eg: linux) you are using plotext with
platform = sys.platform
# According to the docs, this returns one of: 'aix', 'linux', 'win32', 'cygwin',
# 'darwin', or the modified result of `uname -s` on other Unix systems.
if platform in {'win32', 'cygwin'}:
# These are the only two possible outputs on Windows systems
return 'windows'
else:
# Anything that is not Windows and that runs Python is a flavor of Unix
return 'unix'
Since you only ever check this value for Windows, I see no benefit in making a distinction between flavors of Unix. If you do want to make that distinction, why not just return the value of sys.platform
for Unix systems?
Similarly, your function _utility.platform.shell()
returns "cmd"
in any shell that is not Bash. On macOS, the new default is Zsh (which may people use on Linux too), and I’m sure there are people out there still using Csh and even Ksh. But it looks like this value is never actually used anywhere, so I guess it doesn’t matter.
I won’t submit a pull request, because this repository seems to have erased all its history. If you want people to contribute code, you should not do that.
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (5 by maintainers)
@piccolomo A colleague of mine recently evaluated a bunch of git courses for our team members. He recommended this (free) course on Udacity: https://www.udacity.com/course/version-control-with-git--ud123 He thought it would take maybe 10 hours to go all the way through it. If you take a bit of time every day, in no time you should understand one of the most important software development tools we have today.
in short:
git add .
stages all changes in the current directory and subdirectories for commit.git commit
makes the commit.git push
pushes the changes to the remote server.if you need to do
git push -f
you’re doing it wrong.-f
tells git to overwrite things on the remote repository. It should be used only in extreme circumstances. In fact, I think by default GitHub protects the master branch, disallowing this-f
action. Because it doesn’t only hide other peoples’ contributions, but it also invalidates links and commit references other people might be using.Hi @crisluengo,
I reply now to the original issue report. I should have sorted this in the newly updated 4.1.0 version, available on github and pypi.
I have removed the
shell
function and updated theplatform
function to your version.Please let me know if the issue persists.
Thanks also for the git hub guidance! P.S. @Dev-iL, @ethack If you are still up for restoring the GitHub history, I may need the exact terminal commands.
Thanks and all the best, Savino.