prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  Reinstate Fia script (Forest Inventory and Analysis)
  Forest Inventory and Analysis changed the file locations.
  New species table url: https://apps.fs.usda.gov/fiadb-downloads/CSV/REF_SPECIES.csv
  new main:
  
  The new changes needed for FIA
  
          self.urls = {"main": "https://apps.fs.usda.gov/fiadb-downloads/CSV/CSV/",
                       'species': 'https://apps.fs.usda.gov/fiadb-downloads/CSV/REF_SPECIES.csv'}
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `scripts/forest-inventory-analysis.py`
  Content:
  ```
  1 #retriever
  2 """Retriever script for Forest Inventory and Analysis
  3 
  4 """
  5 from __future__ import print_function
  6 from future import standard_library
  7 standard_library.install_aliases()
  8 
  9 import os
  10 import urllib.request, urllib.parse, urllib.error
  11 import zipfile
  12 from decimal import Decimal
  13 from retriever.lib.templates import Script
  14 from retriever.lib.models import Table, Cleanup, no_cleanup
  15 from retriever import HOME_DIR, open_fr, open_fw
  16 
  17 
  18 class main(Script):
  19     def __init__(self, **kwargs):
  20         Script.__init__(self, **kwargs)
  21         self.name = "Forest Inventory and Analysis"
  22         self.shortname = "forest-inventory-analysis"
  23         self.retriever_minimum_version = '2.0.dev'
  24         self.version = '1.2.0'
  25         self.ref = "http://fia.fs.fed.us/"
  26         self.urls = {"main": "http://apps.fs.fed.us/fiadb-downloads/CSV/",
  27                      'species': 'http://apps.fs.fed.us/fiadb-downloads/CSV/REF_SPECIES.csv'}
  28         self.tags = ["plants", "continental-scale", "observational"]
  29         self.citation = "DATEOFDOWNLOAD. Forest Inventory and Analysis Database, St. Paul, MN: U.S. Department of Agriculture, Forest Service, Northern Research Station. [Available only on internet: http://apps.fs.fed.us/fiadb-downloads/datamart.html]"
  30         self.description = """WARNING: This dataset requires downloading many large files and will probably take several hours to finish installing."""
  31         self.addendum = """This dataset requires downloading many large files - please be patient."""
  32 
  33     def download(self, engine=None, debug=False):
  34         Script.download(self, engine, debug)
  35         engine = self.engine
  36 
  37         # download and create species table
  38         table = Table('species')
  39         self.engine.auto_create_table(table, url=self.urls['species'])
  40         self.engine.insert_data_from_url(self.urls['species'])
  41 
  42         # State abbreviations with the year annual inventory began for that state
  43         stateslist = [('AL', 2001), ('AK', 2004), ('AZ', 2001), ('AR', 2000),
  44                       ('CA', 2001), ('CO', 2002), ('CT', 2003), ('DE', 2004),
  45                       ('FL', 2003), ('GA', 1998), ('ID', 2004), ('IL', 2001),
  46                       ('IN', 1999), ('IA', 1999), ('KS', 2001), ('KY', 1999),
  47                       ('LA', 2001), ('ME', 1999), ('MD', 2004), ('MA', 2003),
  48                       ('MI', 2000), ('MN', 1999), ('MO', 1999), ('MS', 2006),
  49                       ('MT', 2003), ('NE', 2001), ('NV', 2004), ('NH', 2002),
  50                       ('NJ', 2004), ('NM', 1999), ('NY', 2002), ('NC', 2003),
  51                       ('ND', 2001), ('OH', 2001), ('OK', 2008), ('OR', 2001),
  52                       ('PA', 2000), ('RI', 2003), ('SC', 1999), ('SD', 2001),
  53                       ('TN', 2000), ('TX', 2001), ('UT', 2000), ('VT', 2003),
  54                       ('VA', 1998), ('WA', 2002), ('WV', 2004), ('WI', 2000),
  55                       ('WY', 2000), ('PR', 2001)]
  56 
  57         tablelist = ["SURVEY", "PLOT", "COND", "SUBPLOT", "SUBP_COND", "TREE", "SEEDLING"]
  58 
  59         for table in tablelist:
  60             for state, year in stateslist:
  61                 engine.download_files_from_archive(self.urls["main"] + state + "_" + table + ".ZIP",
  62                                                    [state + "_" + table + ".csv"])
  63 
  64         for table in tablelist:
  65             print("Scanning data for table %s..." % table)
  66             prep_file_name = "%s.csv" % table
  67             prep_file = open_fw(engine.format_filename(prep_file_name))
  68             this_file = open_fr(engine.format_filename(stateslist[0][0] + "_" + table + ".csv"))
  69             col_names = this_file.readline()
  70             prep_file.write(col_names)
  71             column_names = [col.strip('"') for col in col_names.split(',')]
  72             year_column = column_names.index("INVYR")
  73             this_file.close()
  74 
  75             for state, year in stateslist:
  76                 this_file = open_fr(engine.format_filename(state + "_" + table + ".csv"))
  77                 this_file.readline()
  78                 for line in this_file:
  79                     values = line.split(',')
  80                     this_year = values[year_column]
  81                     if int(this_year) >= year:
  82                         prep_file.write(line)
  83             prep_file.close()
  84             engine.auto_create_table(Table(table), filename=prep_file_name)
  85 
  86             engine.insert_data_from_file(engine.format_filename(prep_file_name))
  87 
  88             try:
  89                 os.remove(engine.format_filename(prep_file_name))
  90             except:
  91                 pass
  92 
  93         return engine
  94 
  95 
  96 SCRIPT = main()
  97
  ```
  --- END FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
golden_diff: diff --git a/scripts/forest-inventory-analysis.py b/scripts/forest-inventory-analysis.py
  --- a/scripts/forest-inventory-analysis.py
  +++ b/scripts/forest-inventory-analysis.py
  @@ -7,12 +7,10 @@
   standard_library.install_aliases()
   
   import os
  -import urllib.request, urllib.parse, urllib.error
  -import zipfile
  -from decimal import Decimal
  +
   from retriever.lib.templates import Script
  -from retriever.lib.models import Table, Cleanup, no_cleanup
  -from retriever import HOME_DIR, open_fr, open_fw
  +from retriever.lib.models import Table
  +from retriever import open_fr, open_fw
   
   
   class main(Script):
  @@ -21,10 +19,10 @@
           self.name = "Forest Inventory and Analysis"
           self.shortname = "forest-inventory-analysis"
           self.retriever_minimum_version = '2.0.dev'
  -        self.version = '1.2.0'
  +        self.version = '1.3.0'
           self.ref = "http://fia.fs.fed.us/"
  -        self.urls = {"main": "http://apps.fs.fed.us/fiadb-downloads/CSV/",
  -                     'species': 'http://apps.fs.fed.us/fiadb-downloads/CSV/REF_SPECIES.csv'}
  +        self.urls = {"main": "https://apps.fs.usda.gov/fiadb-downloads/CSV/",
  +                     'species': 'https://apps.fs.usda.gov/fiadb-downloads/CSV/REF_SPECIES.csv'}
           self.tags = ["plants", "continental-scale", "observational"]
           self.citation = "DATEOFDOWNLOAD. Forest Inventory and Analysis Database, St. Paul, MN: U.S. Department of Agriculture, Forest Service, Northern Research Station. [Available only on internet: http://apps.fs.fed.us/fiadb-downloads/datamart.html]"
           self.description = """WARNING: This dataset requires downloading many large files and will probably take several hours to finish installing."""
  
verification_info: {"golden_diff": "diff --git a/scripts/forest-inventory-analysis.py b/scripts/forest-inventory-analysis.py\n--- a/scripts/forest-inventory-analysis.py\n+++ b/scripts/forest-inventory-analysis.py\n@@ -7,12 +7,10 @@\n standard_library.install_aliases()\n \n import os\n-import urllib.request, urllib.parse, urllib.error\n-import zipfile\n-from decimal import Decimal\n+\n from retriever.lib.templates import Script\n-from retriever.lib.models import Table, Cleanup, no_cleanup\n-from retriever import HOME_DIR, open_fr, open_fw\n+from retriever.lib.models import Table\n+from retriever import open_fr, open_fw\n \n \n class main(Script):\n@@ -21,10 +19,10 @@\n         self.name = \"Forest Inventory and Analysis\"\n         self.shortname = \"forest-inventory-analysis\"\n         self.retriever_minimum_version = '2.0.dev'\n-        self.version = '1.2.0'\n+        self.version = '1.3.0'\n         self.ref = \"http://fia.fs.fed.us/\"\n-        self.urls = {\"main\": \"http://apps.fs.fed.us/fiadb-downloads/CSV/\",\n-                     'species': 'http://apps.fs.fed.us/fiadb-downloads/CSV/REF_SPECIES.csv'}\n+        self.urls = {\"main\": \"https://apps.fs.usda.gov/fiadb-downloads/CSV/\",\n+                     'species': 'https://apps.fs.usda.gov/fiadb-downloads/CSV/REF_SPECIES.csv'}\n         self.tags = [\"plants\", \"continental-scale\", \"observational\"]\n         self.citation = \"DATEOFDOWNLOAD. Forest Inventory and Analysis Database, St. Paul, MN: U.S. Department of Agriculture, Forest Service, Northern Research Station. [Available only on internet: http://apps.fs.fed.us/fiadb-downloads/datamart.html]\"\n         self.description = \"\"\"WARNING: This dataset requires downloading many large files and will probably take several hours to finish installing.\"\"\"\n", "issue": "Reinstate Fia script (Forest Inventory and Analysis)\nForest Inventory and Analysis changed the file locations.\r\nNew species table url: https://apps.fs.usda.gov/fiadb-downloads/CSV/REF_SPECIES.csv\r\nnew main:\r\n\r\nThe new changes needed for FIA\r\n\r\n        self.urls = {\"main\": \"https://apps.fs.usda.gov/fiadb-downloads/CSV/CSV/\",\r\n                     'species': 'https://apps.fs.usda.gov/fiadb-downloads/CSV/REF_SPECIES.csv'}\n", "before_files": [{"content": "#retriever\n\"\"\"Retriever script for Forest Inventory and Analysis\n\n\"\"\"\nfrom __future__ import print_function\nfrom future import standard_library\nstandard_library.install_aliases()\n\nimport os\nimport urllib.request, urllib.parse, urllib.error\nimport zipfile\nfrom decimal import Decimal\nfrom retriever.lib.templates import Script\nfrom retriever.lib.models import Table, Cleanup, no_cleanup\nfrom retriever import HOME_DIR, open_fr, open_fw\n\n\nclass main(Script):\n    def __init__(self, **kwargs):\n        Script.__init__(self, **kwargs)\n        self.name = \"Forest Inventory and Analysis\"\n        self.shortname = \"forest-inventory-analysis\"\n        self.retriever_minimum_version = '2.0.dev'\n        self.version = '1.2.0'\n        self.ref = \"http://fia.fs.fed.us/\"\n        self.urls = {\"main\": \"http://apps.fs.fed.us/fiadb-downloads/CSV/\",\n                     'species': 'http://apps.fs.fed.us/fiadb-downloads/CSV/REF_SPECIES.csv'}\n        self.tags = [\"plants\", \"continental-scale\", \"observational\"]\n        self.citation = \"DATEOFDOWNLOAD. Forest Inventory and Analysis Database, St. Paul, MN: U.S. Department of Agriculture, Forest Service, Northern Research Station. [Available only on internet: http://apps.fs.fed.us/fiadb-downloads/datamart.html]\"\n        self.description = \"\"\"WARNING: This dataset requires downloading many large files and will probably take several hours to finish installing.\"\"\"\n        self.addendum = \"\"\"This dataset requires downloading many large files - please be patient.\"\"\"\n\n    def download(self, engine=None, debug=False):\n        Script.download(self, engine, debug)\n        engine = self.engine\n\n        # download and create species table\n        table = Table('species')\n        self.engine.auto_create_table(table, url=self.urls['species'])\n        self.engine.insert_data_from_url(self.urls['species'])\n\n        # State abbreviations with the year annual inventory began for that state\n        stateslist = [('AL', 2001), ('AK', 2004), ('AZ', 2001), ('AR', 2000),\n                      ('CA', 2001), ('CO', 2002), ('CT', 2003), ('DE', 2004),\n                      ('FL', 2003), ('GA', 1998), ('ID', 2004), ('IL', 2001),\n                      ('IN', 1999), ('IA', 1999), ('KS', 2001), ('KY', 1999),\n                      ('LA', 2001), ('ME', 1999), ('MD', 2004), ('MA', 2003),\n                      ('MI', 2000), ('MN', 1999), ('MO', 1999), ('MS', 2006),\n                      ('MT', 2003), ('NE', 2001), ('NV', 2004), ('NH', 2002),\n                      ('NJ', 2004), ('NM', 1999), ('NY', 2002), ('NC', 2003),\n                      ('ND', 2001), ('OH', 2001), ('OK', 2008), ('OR', 2001),\n                      ('PA', 2000), ('RI', 2003), ('SC', 1999), ('SD', 2001),\n                      ('TN', 2000), ('TX', 2001), ('UT', 2000), ('VT', 2003),\n                      ('VA', 1998), ('WA', 2002), ('WV', 2004), ('WI', 2000),\n                      ('WY', 2000), ('PR', 2001)]\n\n        tablelist = [\"SURVEY\", \"PLOT\", \"COND\", \"SUBPLOT\", \"SUBP_COND\", \"TREE\", \"SEEDLING\"]\n\n        for table in tablelist:\n            for state, year in stateslist:\n                engine.download_files_from_archive(self.urls[\"main\"] + state + \"_\" + table + \".ZIP\",\n                                                   [state + \"_\" + table + \".csv\"])\n\n        for table in tablelist:\n            print(\"Scanning data for table %s...\" % table)\n            prep_file_name = \"%s.csv\" % table\n            prep_file = open_fw(engine.format_filename(prep_file_name))\n            this_file = open_fr(engine.format_filename(stateslist[0][0] + \"_\" + table + \".csv\"))\n            col_names = this_file.readline()\n            prep_file.write(col_names)\n            column_names = [col.strip('\"') for col in col_names.split(',')]\n            year_column = column_names.index(\"INVYR\")\n            this_file.close()\n\n            for state, year in stateslist:\n                this_file = open_fr(engine.format_filename(state + \"_\" + table + \".csv\"))\n                this_file.readline()\n                for line in this_file:\n                    values = line.split(',')\n                    this_year = values[year_column]\n                    if int(this_year) >= year:\n                        prep_file.write(line)\n            prep_file.close()\n            engine.auto_create_table(Table(table), filename=prep_file_name)\n\n            engine.insert_data_from_file(engine.format_filename(prep_file_name))\n\n            try:\n                os.remove(engine.format_filename(prep_file_name))\n            except:\n                pass\n\n        return engine\n\n\nSCRIPT = main()\n", "path": "scripts/forest-inventory-analysis.py"}], "after_files": [{"content": "#retriever\n\"\"\"Retriever script for Forest Inventory and Analysis\n\n\"\"\"\nfrom __future__ import print_function\nfrom future import standard_library\nstandard_library.install_aliases()\n\nimport os\n\nfrom retriever.lib.templates import Script\nfrom retriever.lib.models import Table\nfrom retriever import open_fr, open_fw\n\n\nclass main(Script):\n    def __init__(self, **kwargs):\n        Script.__init__(self, **kwargs)\n        self.name = \"Forest Inventory and Analysis\"\n        self.shortname = \"forest-inventory-analysis\"\n        self.retriever_minimum_version = '2.0.dev'\n        self.version = '1.3.0'\n        self.ref = \"http://fia.fs.fed.us/\"\n        self.urls = {\"main\": \"https://apps.fs.usda.gov/fiadb-downloads/CSV/\",\n                     'species': 'https://apps.fs.usda.gov/fiadb-downloads/CSV/REF_SPECIES.csv'}\n        self.tags = [\"plants\", \"continental-scale\", \"observational\"]\n        self.citation = \"DATEOFDOWNLOAD. Forest Inventory and Analysis Database, St. Paul, MN: U.S. Department of Agriculture, Forest Service, Northern Research Station. [Available only on internet: http://apps.fs.fed.us/fiadb-downloads/datamart.html]\"\n        self.description = \"\"\"WARNING: This dataset requires downloading many large files and will probably take several hours to finish installing.\"\"\"\n        self.addendum = \"\"\"This dataset requires downloading many large files - please be patient.\"\"\"\n\n    def download(self, engine=None, debug=False):\n        Script.download(self, engine, debug)\n        engine = self.engine\n\n        # download and create species table\n        table = Table('species')\n        self.engine.auto_create_table(table, url=self.urls['species'])\n        self.engine.insert_data_from_url(self.urls['species'])\n\n        # State abbreviations with the year annual inventory began for that state\n        stateslist = [('AL', 2001), ('AK', 2004), ('AZ', 2001), ('AR', 2000),\n                      ('CA', 2001), ('CO', 2002), ('CT', 2003), ('DE', 2004),\n                      ('FL', 2003), ('GA', 1998), ('ID', 2004), ('IL', 2001),\n                      ('IN', 1999), ('IA', 1999), ('KS', 2001), ('KY', 1999),\n                      ('LA', 2001), ('ME', 1999), ('MD', 2004), ('MA', 2003),\n                      ('MI', 2000), ('MN', 1999), ('MO', 1999), ('MS', 2006),\n                      ('MT', 2003), ('NE', 2001), ('NV', 2004), ('NH', 2002),\n                      ('NJ', 2004), ('NM', 1999), ('NY', 2002), ('NC', 2003),\n                      ('ND', 2001), ('OH', 2001), ('OK', 2008), ('OR', 2001),\n                      ('PA', 2000), ('RI', 2003), ('SC', 1999), ('SD', 2001),\n                      ('TN', 2000), ('TX', 2001), ('UT', 2000), ('VT', 2003),\n                      ('VA', 1998), ('WA', 2002), ('WV', 2004), ('WI', 2000),\n                      ('WY', 2000), ('PR', 2001)]\n\n        tablelist = [\"SURVEY\", \"PLOT\", \"COND\", \"SUBPLOT\", \"SUBP_COND\", \"TREE\", \"SEEDLING\"]\n\n        for table in tablelist:\n            for state, year in stateslist:\n                engine.download_files_from_archive(self.urls[\"main\"] + state + \"_\" + table + \".ZIP\",\n                                                   [state + \"_\" + table + \".csv\"])\n\n        for table in tablelist:\n            print(\"Scanning data for table %s...\" % table)\n            prep_file_name = \"%s.csv\" % table\n            prep_file = open_fw(engine.format_filename(prep_file_name))\n            this_file = open_fr(engine.format_filename(stateslist[0][0] + \"_\" + table + \".csv\"))\n            col_names = this_file.readline()\n            prep_file.write(col_names)\n            column_names = [col.strip('\"') for col in col_names.split(',')]\n            year_column = column_names.index(\"INVYR\")\n            this_file.close()\n\n            for state, year in stateslist:\n                this_file = open_fr(engine.format_filename(state + \"_\" + table + \".csv\"))\n                this_file.readline()\n                for line in this_file:\n                    values = line.split(',')\n                    this_year = values[year_column]\n                    if int(this_year) >= year:\n                        prep_file.write(line)\n            prep_file.close()\n            engine.auto_create_table(Table(table), filename=prep_file_name)\n\n            engine.insert_data_from_file(engine.format_filename(prep_file_name))\n\n            try:\n                os.remove(engine.format_filename(prep_file_name))\n            except:\n                pass\n\n        return engine\n\n\nSCRIPT = main()\n", "path": "scripts/forest-inventory-analysis.py"}]}