Repository: conan-io/conan

Issue:
Comments are parsed in [imports] section of conanfile.txt
I have the following in my `conanfile.txt` (with the comments as they are in the [docs](http://docs.conan.io/en/latest/manage_deps/conanfile_txt.html#imports)):

```
[imports]
bin, *.dll -> ./build/bin # Copies all dll files from the package "bin" folder to my project "bin" folder
lib, *.dylib* -> ./build/bin # Copies all dylib files from the package "lib" folder to my project "bin" folder
```

And what I get after a `conan install` is:

```
PROJECT: Generated conaninfo.txt
PROJECT: Generated cmake created conanbuildinfo.cmake
Traceback (most recent call last):
  File "<string>", line 10, in <module>
  File "<string>", line 6, in run
  File "C:\Users\lasot\workspace\dev-tools\installer\pyinstaller\conan\build\conan\out00-PYZ.pyz\conans.client.command", line 615, in main
  File "C:\Users\lasot\workspace\dev-tools\installer\pyinstaller\conan\build\conan\out00-PYZ.pyz\conans.client.command", line 529, in run
  File "C:\Users\lasot\workspace\dev-tools\installer\pyinstaller\conan\build\conan\out00-PYZ.pyz\conans.client.command", line 218, in install
  File "C:\Users\lasot\workspace\dev-tools\installer\pyinstaller\conan\build\conan\out00-PYZ.pyz\conans.client.manager", line 205, in install
  File "C:\Users\lasot\workspace\dev-tools\installer\pyinstaller\conan\build\conan\out00-PYZ.pyz\conans.client.importer", line 72, in execute
  File "C:\Users\lasot\workspace\dev-tools\installer\pyinstaller\conan\build\conan\out00-PYZ.pyz\conans.client.file_copier", line 81, in __call__
  File "C:\Users\lasot\workspace\dev-tools\installer\pyinstaller\conan\build\conan\out00-PYZ.pyz\shutil", line 130, in copy2
  File "C:\Users\lasot\workspace\dev-tools\installer\pyinstaller\conan\build\conan\out00-PYZ.pyz\shutil", line 83, in copyfile
IOError: [Errno 22] invalid mode ('wb') or filename: 'D:\\Development\\_VirtualEnvs\\neutron\\neutron\\processing\\compute_informer_order\\build\\bin # Copies all dll files from the package "bin" folder to my project "bin" folder\\zlibd.dll'
```

The last line has the comment inside it, building an invalid path:

 'D:\Development\_VirtualEnvs\neutron\neutron\processing\compute_informer_order\build\bin **# Copies all dll files from the package "bin" folder to my project "bin" folder**\zlibd.dll'

Of course, after removing the comments in `conanfile.txt`, everything works as expected :dancer:

```
PROJECT: Generated conaninfo.txt
PROJECT: Generated cmake created conanbuildinfo.cmake
PROJECT imports(): Copied 32 '.dll' files
```

---

conan version 0.8.5
win7 64bits
python 3.4.3



Discussion:
Yes, this is a bug, please avoid the comments till we fix it, shouldn't be difficult (maybe you want to try? :) :) 
Thanks for reporting


Resolving patch:
diff --git a/conans/client/loader.py b/conans/client/loader.py
--- a/conans/client/loader.py
+++ b/conans/client/loader.py
@@ -131,7 +131,7 @@ class ConanFileTextLoader(object):
     def __init__(self, input_text):
         # Prefer composition over inheritance, the __getattr__ was breaking things
         self._config_parser = ConfigParser(input_text,  ["requires", "generators", "options",
-                                                         "imports"])
+                                                         "imports"], parse_lines=True)
 
     @property
     def requirements(self):
diff --git a/conans/util/config_parser.py b/conans/util/config_parser.py
--- a/conans/util/config_parser.py
+++ b/conans/util/config_parser.py
@@ -8,7 +8,7 @@ class ConfigParser(object):
     as parser.section
     Currently used in ConanInfo and ConanFileTextLoader
     """
-    def __init__(self, text, allowed_fields=None):
+    def __init__(self, text, allowed_fields=None, parse_lines=False):
         self._sections = {}
         self._allowed_fields = allowed_fields or []
         pattern = re.compile("^\[([a-z_]{2,50})\]")
@@ -25,6 +25,9 @@ def __init__(self, text, allowed_fields=None):
                 current_lines = []
                 self._sections[group] = current_lines
             else:
+                if parse_lines:
+                    line = line.split('#')[0]
+                    line = line.strip()
                 current_lines.append(line)
 
     def __getattr__(self, name):


Test patch:
diff --git a/conans/test/conanfile_loader_test.py b/conans/test/conanfile_loader_test.py
--- a/conans/test/conanfile_loader_test.py
+++ b/conans/test/conanfile_loader_test.py
@@ -17,17 +17,17 @@ class ConanLoaderTest(unittest.TestCase):
     def plain_text_parser_test(self):
         # Valid content
         file_content = '''[requires]
-OpenCV/2.4.10@phil/stable
-OpenCV2/2.4.10@phil/stable
+OpenCV/2.4.10@phil/stable # My requirement for CV
+OpenCV2/2.4.10@phil/stable #
 OpenCV3/2.4.10@phil/stable
 [generators]
-one
+one # My generator for this
 two
 [options]
-OpenCV:use_python=True
+OpenCV:use_python=True # Some option
 OpenCV:other_option=False
 OpenCV2:use_python2=1
-OpenCV2:other_option=Cosa
+OpenCV2:other_option=Cosa #
 '''
         parser = ConanFileTextLoader(file_content)
         exp = ['OpenCV/2.4.10@phil/stable',
@@ -43,7 +43,7 @@ def load_conan_txt_test(self):
 one
 two
 [imports]
-OpenCV/bin, * -> ./bin
+OpenCV/bin, * -> ./bin # I need this binaries
 OpenCV/lib, * -> ./lib
 [options]
 OpenCV:use_python=True
diff --git a/conans/test/integration/flat_requirements_test.py b/conans/test/integration/flat_requirements_test.py
--- a/conans/test/integration/flat_requirements_test.py
+++ b/conans/test/integration/flat_requirements_test.py
@@ -5,7 +5,7 @@
                           BUILD_INFO_VISUAL_STUDIO, BUILD_INFO_XCODE)
 from conans.util.files import save, load
 import os
-from conans.test.tools import TestClient, TestServer
+from conans.test.tools import TestClient
 from conans.test.utils.test_files import temp_folder
 
 
@@ -22,9 +22,9 @@ def consumer_with_flat_requirement_test(self):
         # We want to reuse exported Hello0/0.1@lasote/stable
         tmp_dir = temp_folder()
         req_file = '''[requires]
-Hello0/0.1@lasote/stable
+Hello0/0.1@lasote/stable # My req comment
 [generators]
-gcc
+gcc # I need this generator for..
 cmake
 visual_studio
 xcode