Skip to content

Commit

Permalink
g.proj: fix reading input WKT (OSGeo#1582)
Browse files Browse the repository at this point in the history
properly terminate input WKT string

Co-authored-by: Marc Jansen <jansen@terrestris.de>
  • Loading branch information
a0x8o and marcjansen committed May 9, 2024
1 parent 9441e85 commit 04f7859
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 0 deletions.
4 changes: 4 additions & 0 deletions docker/alpine/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -201,10 +201,14 @@ RUN apk add curl && curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py && p

# install external Python API
<<<<<<< HEAD:docker/alpine/Dockerfile
<<<<<<< HEAD:docker/alpine/Dockerfile
RUN pip3 install --upgrade pip six grass-session --ignore-installed six
=======
RUN pip3 install --upgrade grass-session
>>>>>>> da389cd55e (Dockerfile_alpine: fix broken pip six installation (#1568)):docker/alpine/Dockerfile_alpine
=======
RUN pip3 install --upgrade pip six grass-session --ignore-installed six
>>>>>>> 7c10386e82 (g.proj: fix reading input WKT (#1582)):docker/alpine/Dockerfile_alpine

RUN ln -s /usr/local/grass /usr/local/grass7
RUN ln -s /usr/local/grass `grass --config path`
Expand Down
3 changes: 3 additions & 0 deletions general/g.proj/input.c
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ int input_wkt(char *wktfile)
infd = fopen(wktfile, "r");

if (infd) {
<<<<<<< HEAD
<<<<<<< HEAD
size_t wktlen;

Expand All @@ -130,6 +131,8 @@ int input_wkt(char *wktfile)
/* Get rid of newlines */
G_squeeze(buff);
=======
=======
>>>>>>> 7c10386e82 (g.proj: fix reading input WKT (#1582))
size_t wktlen;

wktlen = fread(buff, 1, sizeof(buff), infd);
Expand Down
3 changes: 3 additions & 0 deletions gui/wxpython/gui_core/prompt.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,10 @@ def __init__(self, parent, giface, menuModel):
giface.currentMapsetChanged.connect(self._reloadListOfMaps)
giface.grassdbChanged.connect(self._reloadListOfMaps)
<<<<<<< HEAD
<<<<<<< HEAD
=======
=======
>>>>>>> 7c10386e82 (g.proj: fix reading input WKT (#1582))

def _readHistory(self):
"""Get list of commands from history file"""
Expand Down
3 changes: 3 additions & 0 deletions python/grass/.flake8
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,12 @@ ignore =
E203, # whitespace before ':' (Black)
W503, # line break before binary operator (Black)
<<<<<<< HEAD
<<<<<<< HEAD
=======
E722, # do not use bare 'except'
>>>>>>> 7e8f036e2d (pythonlib: Remove star imports (#1546))
=======
>>>>>>> 7c10386e82 (g.proj: fix reading input WKT (#1582))

per-file-ignores =
# C wrappers call libgis.G_gisinit before importing other modules.
Expand Down
27 changes: 27 additions & 0 deletions scripts/g.extension/g.extension.py
Original file line number Diff line number Diff line change
Expand Up @@ -506,6 +506,29 @@ def replace_shebang_win(python_file):
os.rename(tmp_name, python_file) # rename temp to original name


def replace_shebang_win(python_file):
"""
Replaces "python" with "python3" in python files
using UTF8 encoding on MS Windows
"""

cur_dir = os.path.dirname(python_file)
tmp_name = os.path.join(cur_dir, gscript.tempname(12))

with codecs.open(python_file, "r", encoding="utf8") as in_file, codecs.open(
tmp_name, "w", encoding="utf8"
) as out_file:

for line in in_file:
new_line = line.replace(
"#!/usr/bin/env python\n", "#!/usr/bin/env python3\n"
)
out_file.write(new_line)

os.remove(python_file) # remove original
os.rename(tmp_name, python_file) # rename temp to original name


def urlretrieve(url, filename, *args, **kwargs):
"""Same function as 'urlretrieve', but with the ability to
define headers.
Expand Down Expand Up @@ -1667,11 +1690,15 @@ def install_extension_win(name):
for r, d, f in os.walk(srcdir):
for file in f:
# Filter GRASS module name patterns
<<<<<<< HEAD
<<<<<<< HEAD
if re.search(module_name_pattern, file):
=======
if re.search(r"^[d,db,g,i,m,p,ps,r,r3,s,t,v,wx]\..*[\.py,\.exe]$", file):
>>>>>>> b3579a4902 (g.proj: fix reading input WKT (#1582))
=======
if re.search(r"^[d,db,g,i,m,p,ps,r,r3,s,t,v,wx]\..*[\.py,\.exe]$", file):
>>>>>>> 7c10386e82 (g.proj: fix reading input WKT (#1582))
modulename = os.path.splitext(file)[0]
module_list.append(modulename)
# remove duplicates in case there are .exe wrappers for python scripts
Expand Down

0 comments on commit 04f7859

Please sign in to comment.