Revision: 21970
          http://sourceforge.net/p/bibdesk/svn/21970
Author:   hofman
Date:     2018-02-19 22:27:19 +0000 (Mon, 19 Feb 2018)
Log Message:
-----------
code layout comments and remove unused methods

Modified Paths:
--------------
    trunk/bibdesk/BDSKMathSciNetParser.h
    trunk/bibdesk/BDSKMathSciNetParser.m
    trunk/bibdesk/BDSKNumdamParser.m
    trunk/bibdesk/BDSKProjectEuclidParser.m
    trunk/bibdesk/BDSKZentralblattParser.h
    trunk/bibdesk/BDSKZentralblattParser.m

Modified: trunk/bibdesk/BDSKMathSciNetParser.h
===================================================================
--- trunk/bibdesk/BDSKMathSciNetParser.h        2018-02-19 22:11:51 UTC (rev 
21969)
+++ trunk/bibdesk/BDSKMathSciNetParser.h        2018-02-19 22:27:19 UTC (rev 
21970)
@@ -40,11 +40,7 @@
 #import "BDSKAsynchronousWebParser.h"
 
 
-/*
-       BDSKWebParser subclass for the AMS's MathSciNet pages.
-*/ 
 @interface BDSKMathSciNetParser : BDSKAsynchronousWebParser
-+ (NSArray *) bibTeXRequestsForMRIDs:(NSArray *) IDs referrer:(NSURL *) URL 
error:(NSError **) outError;
-+ (NSArray *) bibItemsFromBibTeXString:(NSString *) bibTeXString 
fromURL:(NSURL *)bibTeXURL error:(NSError **) outError;
-+ (NSURL *) reviewLinkForID:(NSString *) MRID;
++ (NSArray *)bibTeXRequestsForMRIDs:(NSArray *)IDs referrer:(NSURL *)URL 
error:(NSError **)outError;
++ (NSArray *)bibItemsFromBibTeXString:(NSString *)bibTeXString fromURL:(NSURL 
*)bibTeXURL error:(NSError **)outError;
 @end

Modified: trunk/bibdesk/BDSKMathSciNetParser.m
===================================================================
--- trunk/bibdesk/BDSKMathSciNetParser.m        2018-02-19 22:11:51 UTC (rev 
21969)
+++ trunk/bibdesk/BDSKMathSciNetParser.m        2018-02-19 22:27:19 UTC (rev 
21970)
@@ -47,10 +47,8 @@
 
 @implementation BDSKMathSciNetParser
 
-/*
- MathSciNet is mirrored across different servers, don't use the server name to 
recognise the URL.
- Instead recognise all URLs beginning with 'mathscinet', to match both general 
MatSciNet URLs like <https://www.ams.org/mathscinet/...>  and MathSciNet 
reference URLS <https://www.ams.org/mathscinet-getitem?...>.
-*/
+// MathSciNet is mirrored across different servers, don't use the server name 
to recognise the URL.
+// Instead recognise all URLs beginning with 'mathscinet', to match both 
general MatSciNet URLs like <https://www.ams.org/mathscinet/...>  and 
MathSciNet reference URLS <https://www.ams.org/mathscinet-getitem?...>.
 + (BOOL)canParseDocument:(DOMDocument *)domDocument xmlDocument:(NSXMLDocument 
*)xmlDocument fromURL:(NSURL *)url{
     
     if ([url path] == nil || [[[url path] lowercaseString] 
hasPrefix:@"/mathscinet"] == NO)
@@ -61,11 +59,9 @@
     return nil != [MRRegexp findInString:[xmlDocument XMLString]];
 }
 
-/*
- Finds strings of type MR1234567 in the current page. 
- Creates a list of their IDs (without leading zeroes), and retrieves the 
BibItems for them.
- Returns an array with those BibItems.
-*/
+// Finds strings of type MR1234567 in the current page.
+// Creates a list of their IDs (without leading zeroes), and retrieves the 
BibItems for them.
+// Returns an array with those BibItems.
 - (void)start {
 
     NSError *error = nil;
@@ -121,23 +117,20 @@
     [self didFinishDownload:download findingItems:results withSuccess:YES 
error:nil];
 }
 
-/*
- Turns an array of MR ID numbers into an array of NSURLRequest objects to 
download the bibTeX citations.
- The referrer: URL argument is used to send requests to the same mirror that 
was used originally.
- */
-+ (NSArray *) bibTeXRequestsForMRIDs:(NSArray *) IDs referrer:(NSURL *) URL 
error:(NSError **) outError {
+// Turns an array of MR ID numbers into an array of NSURLRequest objects to 
download the bibTeX citations.
+// The referrer: URL argument is used to send requests to the same mirror that 
was used originally.
++ (NSArray *)bibTeXRequestsForMRIDs:(NSArray *)IDs referrer:(NSURL *)URL 
error:(NSError **)outError {
     NSError * error;
     
-    /*    Determine the server name to use.
-     If the referring URL's server name contains 'ams', assume we were using a 
mirror server before and continue using that.
-     If not, we're processing MR IDs not coming from a MathSciNet page and use 
the default 'ams.org' server.
-     */
+    // Determine the server name to use.
+    // If the referring URL's server name contains 'ams', assume we were using 
a mirror server before and continue using that.
+    // If not, we're processing MR IDs not coming from a MathSciNet page and 
use the default 'ams.org' server.
     NSString * serverName = [[URL host] lowercaseString];
     if (!serverName || [serverName rangeOfString:@"ams"].location == 
NSNotFound) {
         serverName = @"www.ams.org";
     }
     
-    /* Loop through IDs in batches of MSNBATCHSIZE. */
+    // Loop through IDs in batches of MSNBATCHSIZE. */
     NSUInteger count = [IDs count];
     NSMutableArray * results = [NSMutableArray array];
     NSUInteger firstElement = 0;
@@ -147,7 +140,7 @@
         firstElement += MSNBATCHSIZE;
         
         NSString * queryString = [processArray 
componentsJoinedByString:@"%20or%20"];
-        NSString * URLString = [NSString 
stringWithFormat:@"https://%@/mathscinet/search/publications.html?&fmt=bibtex&pg1=MR&s1=%@";,
 serverName, queryString];
+        NSString * URLString = [NSString 
stringWithFormat:@"%@://%@/mathscinet/search/publications.html?&fmt=bibtex&pg1=MR&s1=%@",
 [URL scheme], serverName, queryString];
         NSURL * bibTeXBatchDownloadURL = [NSURL URLWithString:URLString];
         
         NSURLRequest * request = [NSURLRequest 
requestWithURL:bibTeXBatchDownloadURL 
cachePolicy:NSURLRequestReturnCacheDataElseLoad timeoutInterval:60.0];
@@ -159,31 +152,26 @@
     return results;
 }
 
-/*
- Parses the bibTeX string returned from a request to get an array of BibItems.
- */
-+ (NSArray *) bibItemsFromBibTeXString:(NSString *) bibTeXString 
fromURL:(NSURL *)bibTeXURL error:(NSError **) outError {
+// Parses the bibTeX string returned from a request to get an array of 
BibItems.
++ (NSArray *)bibItemsFromBibTeXString:(NSString *)bibTeXString fromURL:(NSURL 
*)bibTeXURL error:(NSError **)outError {
     NSError * error = nil;
     
     NSXMLDocument * resultsPage = [[[NSXMLDocument alloc] 
initWithXMLString:bibTeXString options: NSXMLDocumentTidyHTML error:&error] 
autorelease];
     
     if ((error != nil)  && (resultsPage == nil)) {
-        /*  Only return with an error if we don't receive an XML object back.
-         NSXMLDocument returns an  NSXMLParserInternalError NSError if markup 
was slightly invalid.
-         MSN sends such markup by including unescaped ampersands in their 
XHTML, but the NSXMLDocumentTidyHTML fixes that problem despite the NSError.
-         */
+        // Only return with an error if we don't receive an XML object back.
+        // NSXMLDocument returns an  NSXMLParserInternalError NSError if 
markup was slightly invalid.
+        // MSN sends such markup by including unescaped ampersands in their 
XHTML, but the NSXMLDocumentTidyHTML fixes that problem despite the NSError.
         if (outError != NULL) { *outError = error; }
         return nil;
     }
     
-    /*    Downloaded BibTeX records sometimes use \"o for umlauts which is 
incorrect and rejected by the parser. Use a regular expression to find and 
replace them. Also add brackets to acute and grave accents, so BibDesk 
translates them to Unicode properly for display.
-     */
+    // Downloaded BibTeX records sometimes use \"o for umlauts which is 
incorrect and rejected by the parser. Use a regular expression to find and 
replace them. Also add brackets to acute and grave accents, so BibDesk 
translates them to Unicode properly for display.
     AGRegex * umlautFixer = [AGRegex regexWithPattern:@"(\\\\[\"'`][a-zA-Z])" 
options:AGRegexMultiline];
     
-    /*    In the returned web page results live inside a <div class="doc"> tag.
-     Each of them is wrapped in a <pre> tag.
-     Find these, kill the potentially superfluous whitespace in there and 
create BibItems for each of them.
-     */
+    // In the returned web page results live inside a <div class="doc"> tag.
+    // Each of them is wrapped in a <pre> tag.
+    // Find these, kill the potentially superfluous whitespace in there and 
create BibItems for each of them.
     NSArray * preArray = [resultsPage 
nodesForXPath:@".//div[@class='doc']/pre" error:&error];
     
     if ( preArray == nil ) {
@@ -208,7 +196,7 @@
     // Add a URL reference pointing to the review's web page to each record.
     for (BibItem * item in results) {
         NSString * MRNumber = [[item citeKey] stringByRemovingPrefix:@"MR"];
-        NSString * MRItemURLString = [NSString 
stringWithFormat:@"https://%@/mathscinet-getitem?mr=%@";, [bibTeXURL host], 
MRNumber];
+        NSString * MRItemURLString = [NSString 
stringWithFormat:@"%@://%@/mathscinet-getitem?mr=%@", [bibTeXURL scheme], 
[bibTeXURL host], MRNumber];
         NSURL * MRItemURL = [NSURL URLWithString:MRItemURLString];
         [item addFileForURL:MRItemURL autoFile:NO runScriptHook:NO];
     }
@@ -216,19 +204,7 @@
     return results;
 }
 
-/*
- Returns URL to the review for a given ID.
- It always points to the default server.
-*/
-+ (NSURL *) reviewLinkForID: (NSString *) MRID {
-       NSString * MRItemURLString = [NSString 
stringWithFormat:@"https://www.ams.org/mathscinet-getitem?mr=%@";, MRID];
-       NSURL * MRItemURL = [NSURL URLWithString:MRItemURLString];
-       return MRItemURL;
-}
-
-/*
- Array with site description dictionary for ams.org/mathscinet.
-*/
+// Array with site description dictionary for ams.org/mathscinet.
 + (NSDictionary *)parserInfo {
        NSString *parserDescription = NSLocalizedString(@"Database of 
Mathematical Reviews by the American Mathematical Society.", @"Description for 
MathSciNet site");
        return [BDSKWebParser parserInfoWithName:@"MathSciNet" 
address:@"https://www.ams.org/mathscinet/"; description: parserDescription 
feature:BDSKParserFeatureSubscription];

Modified: trunk/bibdesk/BDSKNumdamParser.m
===================================================================
--- trunk/bibdesk/BDSKNumdamParser.m    2018-02-19 22:11:51 UTC (rev 21969)
+++ trunk/bibdesk/BDSKNumdamParser.m    2018-02-19 22:27:19 UTC (rev 21970)
@@ -47,9 +47,7 @@
 
 @implementation BDSKNumdamParser
 
-/*
- Recognise Numdam pages by their server name ending in numdam.org.
- */
+// Recognise Numdam pages by their server name ending in numdam.org.
 + (BOOL)canParseDocument:(DOMDocument *)domDocument xmlDocument:(NSXMLDocument 
*)xmlDocument fromURL:(NSURL *)url{
     
     if ([url host] == nil || [[[url host] lowercaseString] 
hasSuffix:@"numdam.org"])
@@ -61,10 +59,8 @@
     return [tableCells count] > 0;
 }
 
-/*
- Find references from Zentralblatt Math referred to by the page. Then look 
them up. Insert link to NUMDAM in the item's own record.
- (Support for MatSciNet is currently commented out as their lookup script 
requires online-style MR1234567 identifiers and NUMDAM uses paper-style 
identifiers a la 16,957b.)
- */
+// Find references from Zentralblatt Math referred to by the page. Then look 
them up. Insert link to NUMDAM in the item's own record.
+// (Support for MatSciNet is currently commented out as their lookup script 
requires online-style MR1234567 identifiers and NUMDAM uses paper-style 
identifiers a la 16,957b.)
 - (void)start {
 
     NSError * error = nil;

Modified: trunk/bibdesk/BDSKProjectEuclidParser.m
===================================================================
--- trunk/bibdesk/BDSKProjectEuclidParser.m     2018-02-19 22:11:51 UTC (rev 
21969)
+++ trunk/bibdesk/BDSKProjectEuclidParser.m     2018-02-19 22:27:19 UTC (rev 
21970)
@@ -47,9 +47,7 @@
 
 @implementation BDSKProjectEuclidParser
 
-/*
- Recognise Project Euclid pages by their server name ending in 
projecteuclid.org.
-*/
+// Recognise Project Euclid pages by their server name ending in 
projecteuclid.org.
 + (BOOL)canParseDocument:(DOMDocument *)domDocument xmlDocument:(NSXMLDocument 
*)xmlDocument fromURL:(NSURL *)url{
        
     if ([url host] == nil || [[[url host] lowercaseString] 
hasSuffix:@"projecteuclid.org"])
@@ -61,9 +59,7 @@
        return [identifiers count] > 0;
 }
 
-/*
- Find references for Mathematical Reviews and Zentralblatt Math in the page. 
Then look them up, giving preference to MSN if both are available.
-*/
+// Find references for Mathematical Reviews and Zentralblatt Math in the page. 
Then look them up, giving preference to MSN if both are available.
 - (void)start {
 
        NSError * error;

Modified: trunk/bibdesk/BDSKZentralblattParser.h
===================================================================
--- trunk/bibdesk/BDSKZentralblattParser.h      2018-02-19 22:11:51 UTC (rev 
21969)
+++ trunk/bibdesk/BDSKZentralblattParser.h      2018-02-19 22:27:19 UTC (rev 
21970)
@@ -41,7 +41,6 @@
 
 
 @interface BDSKZentralblattParser : BDSKAsynchronousWebParser
-+ (NSArray *) bibTeXRequestsForZMathIDs:(NSArray *) IDs referrer:(NSURL *) 
referrer error:(NSError **) outError;
-+ (NSArray *) bibItemsFromBibTeXString:(NSString *) bibTeXString 
fromURL:(NSURL *)bibTeXURL error:(NSError **) outError;
-+ (NSURL *) reviewLinkForID: (NSString *) ZblID;
++ (NSArray *)bibTeXRequestsForZMathIDs:(NSArray *)IDs referrer:(NSURL 
*)referrer error:(NSError **) outError;
++ (NSArray *)bibItemsFromBibTeXString:(NSString *)bibTeXString fromURL:(NSURL 
*)bibTeXURL error:(NSError **)outError;
 @end

Modified: trunk/bibdesk/BDSKZentralblattParser.m
===================================================================
--- trunk/bibdesk/BDSKZentralblattParser.m      2018-02-19 22:11:51 UTC (rev 
21969)
+++ trunk/bibdesk/BDSKZentralblattParser.m      2018-02-19 22:27:19 UTC (rev 
21970)
@@ -47,10 +47,8 @@
 
 @implementation BDSKZentralblattParser
 
-/*
- Zentralblatt Math is mirrored across several servers. See 
http://www.zentralblatt-math.org/zmath/en/mirrors/ .
- Accept URLs whose path begins with zmath. As sometimes paths begin with 
multiple slashes, trim those first.
-*/
+// Zentralblatt Math is mirrored across several servers. See 
http://www.zentralblatt-math.org/zmath/en/mirrors/ .
+// Accept URLs whose path begins with zmath. As sometimes paths begin with 
multiple slashes, trim those first.
 + (BOOL)canParseDocument:(DOMDocument *)domDocument xmlDocument:(NSXMLDocument 
*)xmlDocument fromURL:(NSURL *)url{
     
     if ([url path] == nil || [[[url path] lowercaseString] 
hasPrefix:@"/zmath"] == NO)
@@ -61,11 +59,9 @@
        return nil != [ZMathRegexp findInString:[xmlDocument XMLString]];
 }
 
-/*
- Find occurrences of strings Zbl [pre]1234.56789 or JFM 12.3456.78 on the page.
- Extract their IDs and look them up.
- Return the resulting BibItems.
-*/     
+// Find occurrences of strings Zbl [pre]1234.56789 or JFM 12.3456.78 on the 
page.
+// Extract their IDs and look them up.
+// Return the resulting BibItems.
 - (void)start {
 
     NSError *error = nil;
@@ -121,16 +117,13 @@
 [self didFinishDownload:download findingItems:results withSuccess:YES 
error:nil];
 }
 
-/*
- Turns an array of Zentralblatt Math IDs into an array of NSURLRequest objects 
for bibtex data.
- */
-+ (NSArray *) bibTeXRequestsForZMathIDs:(NSArray *) IDs referrer:(NSURL *) 
referrer error:(NSError **) outError {
+// Turns an array of Zentralblatt Math IDs into an array of NSURLRequest 
objects for bibtex data.
++ (NSArray *)bibTeXRequestsForZMathIDs:(NSArray *)IDs referrer:(NSURL 
*)referrer error:(NSError **)outError {
     NSError * error;
     
-    /*    Determine the server name to use.
-     If the referring URL's path begins with '/zmath', assume we are using a 
Zentralblatt mirror server before and continue using that.
-     If not, use the default server instead.
-     */
+    //    Determine the server name to use.
+    // If the referring URL's path begins with '/zmath', assume we are using a 
Zentralblatt mirror server before and continue using that.
+    // If not, use the default server instead.
     NSString * serverName = [[referrer host] lowercaseString];
     if ( [BDSKZentralblattParser canParseDocument:nil xmlDocument:nil 
fromURL:referrer] ) {
         if ( [[referrer path] rangeOfString:@"/ZMATH/zmath"].location != 
NSNotFound ) {
@@ -166,10 +159,8 @@
     return results;
 }
 
-/*
- Parses a returned bibTeX string to get an array of BibItems.
- */
-+ (NSArray *) bibItemsFromBibTeXString:(NSString *) bibTeXString 
fromURL:(NSURL *)bibTeXURL error:(NSError **) outError{
+// Parses a returned bibTeX string to get an array of BibItems.
++ (NSArray *)bibItemsFromBibTeXString:(NSString *)bibTeXString fromURL:(NSURL 
*)bibTeXURL error:(NSError **)outError{
     /*    ZMath sometimes uses \"o for umlauts which is incorrect, fix that by 
adding brackets around it for the parser to work. Also add brackets to acute 
and grave accents, so BibDesk translates them to Unicode properly for display */
     AGRegex * umlautFixer = [AGRegex regexWithPattern:@"(\\\\[\"'`][a-zA-Z])" 
options:AGRegexMultiline];
 
@@ -180,27 +171,16 @@
     
     // Add a URL reference to the review's web page to each record.
     for (BibItem * item in results) {
-        NSString * ZMathNumber = [item citeKey];
-        NSURL * reviewURL = [BDSKZentralblattParser 
reviewLinkForID:ZMathNumber];
-        [item addFileForURL:reviewURL autoFile:NO runScriptHook:NO];
+        NSString * ZMathID = [item citeKey];
+        NSString * ZMathItemURLString = [NSString 
stringWithFormat:@"https://zbmath.org/search/?format=complete&q=an:%@";, 
ZMathID];
+        NSURL * ZMathItemURL = [NSURL URLWithString:ZMathItemURLString];
+        [item addFileForURL:ZMathItemURL autoFile:NO runScriptHook:NO];
     }
     
     return results;
 }
 
-/*
- Returns URL to the review for a given ID.
- Always uses the default server.
-*/
-+ (NSURL *) reviewLinkForID: (NSString *) ZMathID {
-       NSString * ZMathItemURLString = [NSString 
stringWithFormat:@"https://zbmath.org/search/?format=complete&q=an:%@";, 
ZMathID];
-       NSURL * ZMathItemURL = [NSURL URLWithString:ZMathItemURLString];
-       return ZMathItemURL;
-}
-
-/*
- Array with site description dictionary for main www.zentralblatt-math.org.
-*/
+// Array with site description dictionary for main www.zentralblatt-math.org.
 + (NSDictionary *)parserInfo {
        NSString * parserDescription = NSLocalizedString(@"Database of 
Zentralblatt Mathematik with reviews of mathematical papers. Only the first 
three search results are displayed without a subscription.", @"Description for 
Zentralblatt Math site.");
        return [BDSKWebParser parserInfoWithName:@"Zentralblatt Math" 
address:@"https://zbmath.org/"; description: parserDescription 
feature:BDSKParserFeatureSubscription];

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Bibdesk-commit mailing list
Bibdesk-commit@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bibdesk-commit

Reply via email to