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

Projects
None yet
2 participants
@loicgasser
Contributor

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 changed the title from Add support for relative path for include to Add support for relative path for nested include Aug 4, 2017

@geographika

This comment has been minimized.

Show comment
Hide comment
@geographika

geographika Aug 7, 2017

Owner

@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.

Owner

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

This comment has been minimized.

Show comment
Hide comment
@loicgasser

loicgasser Aug 7, 2017

Contributor

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

Contributor

loicgasser commented Aug 7, 2017

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

@@ -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

Contributor

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

@loicgasser

loicgasser Aug 10, 2017

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

Contributor

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

@loicgasser

loicgasser Aug 10, 2017

Contributor

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

@geographika geographika merged commit e526cdd into geographika:master Aug 15, 2017

1 check failed

continuous-integration/travis-ci/pr The Travis CI build failed
Details
@geographika

This comment has been minimized.

Show comment
Hide comment
@geographika

geographika Aug 15, 2017

Owner

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

Owner

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