Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for relative path for nested include #28

Merged
merged 7 commits into from Aug 15, 2017

Conversation

@loicgasser
Copy link
Contributor

@loicgasser loicgasser commented Aug 4, 2017

Not sure what you tried to accomplish with cwd, append absolute paths?

According to me in mapfile you have either

  • relative paths
  • absolute paths

It seems that it was overriden every time when calling parse_file, which is not something I'd expect and I couldn't find any test for cwd argument.

Hope that you are happy with these changes.

In the utils section I added all the options you can give the parser (namely add_linebreaks for loads and expand_includes + add_linebreaks for load)

DOC:
http://mapserver.org/mapfile/include.html

Supported in versions 4.10 and higher.

The name of the file to be included MUST be quoted (single or double quotes).

Includes may be nested, up to 5 deep.

File location can be given as a full path to the file, or (in MapServer >= 4.10.1) as a path relative to the mapfile.
@loicgasser loicgasser force-pushed the loicgasser:cwd_override branch 2 times, most recently from a175521 to 737afae Aug 4, 2017
@loicgasser loicgasser changed the title Add support for relative path for include Add support for relative path for nested include Aug 4, 2017
@geographika
Copy link
Owner

@geographika geographika commented Aug 7, 2017

@loicgasser - I'll need to get some time to review this in more detail. Thanks for the comments and pull request. From memory I was using the cwd parameter so that I could load a mapfile from a string with relative includes, and load these from disk.

@loicgasser
Copy link
Contributor Author

@loicgasser loicgasser commented Aug 7, 2017

ok thanks, I can adapt/change it if you guide me.

@loicgasser loicgasser force-pushed the loicgasser:cwd_override branch from 49c4e37 to 7bd5fbc Aug 8, 2017
@@ -66,11 +68,9 @@ def open_file(self, fn):
raise

def parse_file(self, fn):

self.cwd = os.path.dirname(fn)

This comment has been minimized.

@loicgasser

loicgasser Aug 10, 2017
Author Contributor

main issue was that. always the same cwd which was overriden here


assert (len(parts) == 2)
assert (parts[0].lower() == 'include')
fn = os.path.join(self.cwd, self.strip_quotes(parts[1]))

This comment has been minimized.

@loicgasser

loicgasser Aug 10, 2017
Author Contributor

and as a result this would not follow relative nested paths.

geographika added 6 commits Aug 15, 2017
@geographika geographika merged commit e526cdd into geographika:master Aug 15, 2017
1 check failed
1 check failed
continuous-integration/travis-ci/pr The Travis CI build failed
Details
@geographika
Copy link
Owner

@geographika geographika commented Aug 15, 2017

@loicgasser - thanks for this. Merged. I increased the line length for flake8 as the default of 80 is quite low.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants
You can’t perform that action at this time.