summaryrefslogtreecommitdiffstats
path: root/src/translators/risimporter.cpp
diff options
context:
space:
mode:
authorSlávek Banko <slavek.banko@axis.cz>2014-03-03 13:46:44 +0100
committerSlávek Banko <slavek.banko@axis.cz>2014-03-03 13:46:44 +0100
commit2e02da046d3e56cdf4744f644af35ad07424f48b (patch)
treef2dcf353aa2338eae1c2ff2c41af971c580c2762 /src/translators/risimporter.cpp
parent3c13229d98167ae4ae0710d5eeef23fef5005bf0 (diff)
downloadtellico-2e02da046d3e56cdf4744f644af35ad07424f48b.tar.gz
tellico-2e02da046d3e56cdf4744f644af35ad07424f48b.zip
Update to upstream version 1.3.6
Diffstat (limited to 'src/translators/risimporter.cpp')
-rw-r--r--src/translators/risimporter.cpp23
1 files changed, 22 insertions, 1 deletions
diff --git a/src/translators/risimporter.cpp b/src/translators/risimporter.cpp
index 735368c..0158708 100644
--- a/src/translators/risimporter.cpp
+++ b/src/translators/risimporter.cpp
@@ -188,7 +188,7 @@ void RISImporter::readURL(const KURL& url_, int n, const TQDict<Data::Field>& ri
// technically, the spec requires a space immediately after the hyphen
// however, at least one website (Springer) outputs RIS with no space after the final "ER -"
// so just strip the white space later
- // also be gracious and allow only any amount of space before hyphen
+ // also be gracious and allow any amount of space before hyphen
TQRegExp rx(TQString::fromLatin1("^(\\w\\w)\\s+-(.*)$"));
TQString currLine, nextLine;
for(currLine = t.readLine(); !m_cancelled && !currLine.isNull(); currLine = nextLine, j += currLine.length()) {
@@ -312,4 +312,25 @@ void RISImporter::slotCancel() {
m_cancelled = true;
}
+bool RISImporter::maybeRIS(const KURL& url_) {
+ TQString text = FileHandler::readTextFile(url_, true /*quiet*/);
+ if(text.isEmpty()) {
+ return false;
+ }
+
+ // bare bones check, strip white space at beginning
+ // and then first text line must be valid RIS
+ TQTextIStream t(&text);
+
+ TQRegExp rx(TQString::fromLatin1("^(\\w\\w)\\s+-(.*)$"));
+ TQString currLine;
+ for(currLine = t.readLine(); !currLine.isNull(); currLine = t.readLine()) {
+ if(currLine.stripWhiteSpace().isEmpty()) {
+ continue;
+ }
+ break;
+ }
+ return rx.exactMatch(currLine);
+}
+
#include "risimporter.moc"