Skip to content

Commit

Permalink
remove locale exporters
Browse files Browse the repository at this point in the history
  • Loading branch information
pdiakumis committed Jun 20, 2024
1 parent d495d0b commit 1486740
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 43 deletions.
6 changes: 0 additions & 6 deletions pcgr/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,12 +130,6 @@ def cli():
optional_other.add_argument("--debug", action="store_true", help="Print full commands to log")
optional_other.add_argument("--pcgrr_conda", default="pcgrr", help="pcgrr conda env name (default: %(default)s)")

# Set locale since apptainer on HPC gives warnings
#locale_to_use = utils.get_locale()
#os.environ["LANGUAGE"] = locale_to_use
#os.environ["LANG"] = locale_to_use
#os.environ["LC_ALL"] = locale_to_use

# Parse required and optional arguments
args = parser.parse_args()
arg_dict = vars(args)
Expand Down
37 changes: 0 additions & 37 deletions pcgr/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,40 +210,3 @@ def check_tabix_file(fname: str, logger = None) -> bool:
check_file_exists(tabix_file)
return(True)

def locale_export():
"""
https://github.com/bcbio/bcbio-nextgen/blob/855c7ae/bcbio/utils.py#L885
"""
locale_to_use = get_locale()
return f"export LC_ALL={locale_to_use} && export LANG={locale_to_use} && "

def get_locale():
"""
https://github.com/bcbio/bcbio-nextgen/blob/855c7ae/bcbio/utils.py#L895
Looks up available locales on the system to find an appropriate one to pick,
defaulting to C.UTF-8 which is globally available on newer systems. Prefers
C.UTF-8 and en_US encodings, if available
"""
default_locale = "C.UTF-8"
preferred_locales = {"c.utf-8", "c.utf8", "en_us.utf-8", "en_us.utf8"}
locale_to_use = None
try:
locales = subprocess.check_output(["locale", "-a"]).decode(errors="ignore").split("\n")
except subprocess.CalledProcessError:
locales = []
# check for preferred locale
for locale in locales:
if locale.lower() in preferred_locales:
locale_to_use = locale
break
# if preferred locale not available take first UTF-8 locale
if not locale_to_use:
for locale in locales:
if locale.lower().endswith(("utf-8", "utf8")):
locale_to_use = locale
break
# if locale listing not available, try using the default locale
if not locale_to_use:
locale_to_use = default_locale
return locale_to_use

0 comments on commit 1486740

Please sign in to comment.