From 0c8b2de2daa887c014004218f443296cd1bcb548 Mon Sep 17 00:00:00 2001 From: emkael Date: Fri, 23 Oct 2015 23:11:40 +0200 Subject: * path parsing fixes --- rrb2txt.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/rrb2txt.py b/rrb2txt.py index e14ec9c..8586f11 100644 --- a/rrb2txt.py +++ b/rrb2txt.py @@ -4,6 +4,7 @@ import sys import os import re import urlparse +import lxml from bs4 import BeautifulSoup, Comment from glob import glob @@ -425,13 +426,18 @@ class RRBTxtGen(object): self.__directory = directory def generate(self): - file_prefix = os.path.dirname(self.__directory).split('/')[-1] + file_prefix = os.path.abspath( + self.__directory).strip(os.sep).split(os.sep)[-1] header = self.get_header() + [''] output = self.compile_dir() for filepath, rows in output.iteritems(): - output_file = open(file_prefix + filepath + '.txt', 'w') + output_file = open(os.path.join( + os.path.abspath(self.__directory), + file_prefix) + filepath + '.txt', 'w') + print os.path.abspath(self.__directory), file_prefix + print os.path.join(os.path.abspath(self.__directory), file_prefix) for line in header: output_file.write(line.encode('windows-1250') + '\n') for row in rows: -- cgit v1.2.3