In [45]:
url = 'https://osf.io/cp86f/download'
outfn = 'sociology-jstor-basicall.doc ___ c'
            
In [40]:
data_files = {
    'sociology-wos': 'https://files.osf.io/v1/resources/9vx4y/providers/osfstorage/5eded795c67d30014e1f3714/?zip='
}
In [43]:
download_file(data_files['sociology-wos'], Path())
Out[43]:
'test.zip'
In [44]:
%pwd
Out[44]:
'G:\\My Drive\\projects\\qualitative analysis of literature\\post 5-12-2020\\git repository _ citation-deaths\\knowknow'

ahhhhhh

In [87]:
!pip install -e git+https://github.com/IQSS/dataverse-client-python.git#egg=dataverse
Obtaining dataverse from git+https://github.com/IQSS/dataverse-client-python.git#egg=dataverse
  Cloning https://github.com/IQSS/dataverse-client-python.git to c:\users\amcga\envs\citation-deaths\src\dataverse
Requirement already satisfied: bleach>=1.2.2 in c:\users\amcga\envs\citation-deaths\lib\site-packages (from dataverse) (3.1.5)
Requirement already satisfied: requests>=2.2.1 in c:\users\amcga\envs\citation-deaths\lib\site-packages (from dataverse) (2.23.0)
Requirement already satisfied: lxml>=3.2.5 in c:\users\amcga\envs\citation-deaths\lib\site-packages (from dataverse) (4.4.1)
Requirement already satisfied: webencodings in c:\users\amcga\envs\citation-deaths\lib\site-packages (from bleach>=1.2.2->dataverse) (0.5.1)
Requirement already satisfied: packaging in c:\users\amcga\envs\citation-deaths\lib\site-packages (from bleach>=1.2.2->dataverse) (20.3)
Requirement already satisfied: six>=1.9.0 in c:\users\amcga\envs\citation-deaths\lib\site-packages (from bleach>=1.2.2->dataverse) (1.14.0)
Requirement already satisfied: urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 in c:\users\amcga\envs\citation-deaths\lib\site-packages (from requests>=2.2.1->dataverse) (1.25.9)
Requirement already satisfied: idna<3,>=2.5 in c:\users\amcga\envs\citation-deaths\lib\site-packages (from requests>=2.2.1->dataverse) (2.9)
Requirement already satisfied: certifi>=2017.4.17 in c:\users\amcga\envs\citation-deaths\lib\site-packages (from requests>=2.2.1->dataverse) (2020.4.5.1)
Requirement already satisfied: chardet<4,>=3.0.2 in c:\users\amcga\envs\citation-deaths\lib\site-packages (from requests>=2.2.1->dataverse) (3.0.4)
Requirement already satisfied: pyparsing>=2.0.2 in c:\users\amcga\envs\citation-deaths\lib\site-packages (from packaging->bleach>=1.2.2->dataverse) (2.4.7)
Installing collected packages: dataverse
  Running setup.py develop for dataverse
Successfully installed dataverse
  Running command git clone -q https://github.com/IQSS/dataverse-client-python.git 'c:\users\amcga\envs\citation-deaths\src\dataverse'
WARNING: You are using pip version 20.1; however, version 20.1.1 is available.
You should consider upgrading via the 'c:\users\amcga\envs\citation-deaths\scripts\python.exe -m pip install --upgrade pip' command.
In [1]:
from dataverse import Connection

host = 'dataverse.harvard.edu'                  # All clients >4.0 are supported
token = '585f5536-98d4-43b3-b2b7-014055329ae1'  # Generated at /account/apitoken

connection = Connection(host, token)
# For non-https connections (e.g. local dev environment), try:
#   connection = Connection(host, token, use_https=False)
In [ ]:
dataverse = connection.get_dataverse('harvard')

dataset = dataverse.get_dataset_by_doi('DOI:10.5072/FK2/ABC123')
files = dataset.get_files('latest')
In [64]:
import sys; sys.path.append(_dh[0].split("knowknow")[0])
from knowknow import *
In [35]:
def list_from_osf(project='9vx4y'):
    print("Looking for files in project '%s' in OSF" % project)
    import subprocess
    cmd='osf -p %s list' % project
    process = subprocess.Popen(cmd.split(), stdout=subprocess.PIPE, stderr=subprocess.PIPE)
    out, err = process.communicate()
    
    def fixem(out):
        out = out.decode('utf8').split("\r\n")
        for x in out:
            x = x.strip()
            if x == "":
                continue
            x = x.split("\\")[1] # remove the storage format
            x = x.split("/")[-1] # remove the folder names
            yield x
    
    fnames = list(fixem(out))
    #bases = sorted(set(x.split("___")[0].strip()))
    #types = {
    #    base: sorted(set(x.split("___")[1].strip() if x.split("___")[0].strip()==base))
    #    for base in bases
    #}
    
    #print("databases: ", bases)
    #print("types: ", types)
    
    return fnames
In [39]:
a = list_from_osf()
Looking for files in project '9vx4y' in OSF
In [42]:
print(a[-1])
sociology-jstor-basicall.doc ___ c
In [82]:
def getvar_osf(variable_name, project='9vx4y'):
    print("Downloading 'variables/%s' from '%s'" % (variable_name, project))
    import os
    os.chdir(str(Path(BASEDIR)))
    import subprocess
    cmd = ['osf', '-p', project, 'fetch', 'variables/%s'%variable_name, 'variables/*']
    
    process = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
    out, err = process.communicate()
    
    if len(err.strip()) > 0:
        raise Exception(err.decode('utf8'))
    
    print("Success!")
In [76]:
%pwd
Out[76]:
'G:\\My Drive\\projects\\qualitative analysis of literature\\post 5-12-2020\\git repository _ citation-deaths\\knowknow\\variables'
In [79]:
def getdb_osf(database, project='9vx4y'):
    print("Downloading 'variables/%s ___ *'%database' from '%s'" % (database, project))
    import os
    import subprocess
    
    os.chdir(str(Path(BASEDIR)))
    cmd = ['osf', '-p', project, 'fetch', 'variables/%s ___ *'%database, "variables"]
    
    process = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
    out, err = process.communicate()
    
    print("Success!")
In [84]:
getvar_osf('sociology-jstor.t.top1')
Downloading 'variables/sociology-jstor.t.top1' from '9vx4y'
---------------------------------------------------------------------------
KeyboardInterrupt                         Traceback (most recent call last)
<ipython-input-84-2223602badf1> in <module>
----> 1 getvar_osf('sociology-jstor.t.top1')

<ipython-input-82-01611dc050fc> in getvar_osf(variable_name, project)
      7 
      8     process = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
----> 9     out, err = process.communicate()
     10 
     11     if len(err.strip()) > 0:

C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\lib\subprocess.py in communicate(self, input, timeout)
    962 
    963             try:
--> 964                 stdout, stderr = self._communicate(input, endtime, timeout)
    965             except KeyboardInterrupt:
    966                 # https://bugs.python.org/issue25942

C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\lib\subprocess.py in _communicate(self, input, endtime, orig_timeout)
   1294             # calls communicate again.
   1295             if self.stdout is not None:
-> 1296                 self.stdout_thread.join(self._remaining_time(endtime))
   1297                 if self.stdout_thread.is_alive():
   1298                     raise TimeoutExpired(self.args, orig_timeout)

C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\lib\threading.py in join(self, timeout)
   1042 
   1043         if timeout is None:
-> 1044             self._wait_for_tstate_lock()
   1045         else:
   1046             # the behavior of a negative timeout isn't documented, but

C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\lib\threading.py in _wait_for_tstate_lock(self, block, timeout)
   1058         if lock is None:  # already determined that the C code is done
   1059             assert self._is_stopped
-> 1060         elif lock.acquire(block, timeout):
   1061             lock.release()
   1062             self._stop()

KeyboardInterrupt: 
In [ ]:
def put_in_osf(project='9vx4y'):
    cmd='osf -p %s -u amcgail2@gmail.com upload -r . variables' % project
In [5]:
%cd ..\variables
G:\My Drive\projects\qualitative analysis of literature\post 5-12-2020\git repository _ citation-deaths\knowknow\variables
In [9]:
%pwd
Out[9]:
'G:\\My Drive\\projects\\qualitative analysis of literature\\post 5-12-2020\\git repository _ citation-deaths\\knowknow\\variables'
In [ ]:
 
In [6]:
!osf init
^C
In [7]:
%env OSF_PASSWORD=S00perperfundo
env: OSF_PASSWORD=S00perperfundo
In [11]:
from osfclient.cli import upload
In [12]:
%ls
 Volume in drive G is Google Drive File Stream
 Volume Serial Number is 1983-1116

 Directory of G:\My Drive\projects\qualitative analysis of literature\post 5-12-2020\git repository _ citation-deaths\knowknow\variables

06/08/2020  01:47 PM    <DIR>          .
06/08/2020  01:35 PM    <DIR>          ..
05/20/2020  01:03 AM    <DIR>          .ipynb_checkpoints
05/19/2020  09:25 PM        16,321,025 sociology-jstor.cysum
05/19/2020  09:15 PM         1,097,662 sociology-jstor.doc ___ a
05/19/2020  09:15 PM        42,608,984 sociology-jstor.doc ___ a.c
05/19/2020  09:15 PM         4,159,056 sociology-jstor.doc ___ a.fj.fy
05/22/2020  09:43 PM        14,454,401 sociology-jstor.doc ___ c
05/22/2020  09:43 PM        35,326,744 sociology-jstor.doc ___ c.c
05/22/2020  09:43 PM        42,563,955 sociology-jstor.doc ___ c.fa
05/22/2020  09:43 PM        33,662,327 sociology-jstor.doc ___ c.fj
05/22/2020  09:43 PM        35,779,163 sociology-jstor.doc ___ c.fy
05/22/2020  09:43 PM        58,770,605 sociology-jstor.doc ___ c.t
05/22/2020  09:43 PM         1,097,496 sociology-jstor.doc ___ fa
05/22/2020  09:43 PM         4,155,720 sociology-jstor.doc ___ fa.fj.fy
05/22/2020  09:43 PM             1,562 sociology-jstor.doc ___ fj
05/22/2020  09:43 PM            89,415 sociology-jstor.doc ___ fj.fy
05/22/2020  09:43 PM         5,479,890 sociology-jstor.doc ___ fj.t
05/22/2020  09:43 PM               637 sociology-jstor.doc ___ fy
05/22/2020  09:43 PM         6,553,027 sociology-jstor.doc ___ fy.t
05/22/2020  09:43 PM           178,145 sociology-jstor.doc ___ t
05/19/2020  09:25 PM         3,987,055 sociology-jstor.included_citations
05/26/2020  10:38 AM             1,369 sociology-jstor.included_journals
05/19/2020  09:15 PM         1,099,259 sociology-jstor.ind ___ a
05/19/2020  09:15 PM        42,608,984 sociology-jstor.ind ___ a.c
05/19/2020  09:15 PM         4,159,259 sociology-jstor.ind ___ a.fj.fy
05/22/2020  09:43 PM        14,454,516 sociology-jstor.ind ___ c
05/22/2020  09:43 PM        35,332,587 sociology-jstor.ind ___ c.c
05/22/2020  09:43 PM        42,563,955 sociology-jstor.ind ___ c.fa
05/22/2020  09:43 PM        33,662,337 sociology-jstor.ind ___ c.fj
05/22/2020  09:43 PM        35,779,163 sociology-jstor.ind ___ c.fy
05/22/2020  09:43 PM        58,770,607 sociology-jstor.ind ___ c.t
05/22/2020  09:43 PM         1,099,090 sociology-jstor.ind ___ fa
05/22/2020  09:43 PM         4,155,923 sociology-jstor.ind ___ fa.fj.fy
05/22/2020  09:43 PM             1,584 sociology-jstor.ind ___ fj
05/22/2020  09:43 PM            90,624 sociology-jstor.ind ___ fj.fy
05/22/2020  09:43 PM         5,480,335 sociology-jstor.ind ___ fj.t
05/22/2020  09:43 PM               656 sociology-jstor.ind ___ fy
05/22/2020  09:43 PM         6,553,141 sociology-jstor.ind ___ fy.t
05/22/2020  09:43 PM           179,218 sociology-jstor.ind ___ t
05/24/2020  03:25 PM             9,255 sociology-jstor.t.top1
05/25/2020  01:32 AM           544,492 sociology-jstor.t.ysum
05/19/2020  09:40 PM           181,107 sociology-jstor.top1
05/21/2020  08:28 PM           286,045 sociology-jstor.tysum
05/25/2020  03:49 PM         4,270,279 sociology-jstor-basicall.doc ___ c
05/25/2020  03:50 PM        35,333,873 sociology-jstor-basicall.doc ___ c.c
05/25/2020  03:50 PM        41,757,719 sociology-jstor-basicall.doc ___ c.c.fy
05/25/2020  03:50 PM        42,567,375 sociology-jstor-basicall.doc ___ c.fa
05/25/2020  03:50 PM        19,820,901 sociology-jstor-basicall.doc ___ c.fj
05/25/2020  03:50 PM        22,696,881 sociology-jstor-basicall.doc ___ c.fy
05/25/2020  03:49 PM         1,321,470 sociology-jstor-basicall.doc ___ fa
05/25/2020  03:50 PM         4,155,253 sociology-jstor-basicall.doc ___ fa.fj.fy
05/25/2020  03:49 PM             1,561 sociology-jstor-basicall.doc ___ fj
05/25/2020  03:49 PM            86,949 sociology-jstor-basicall.doc ___ fj.fy
05/25/2020  03:50 PM         6,072,193 sociology-jstor-basicall.doc ___ fj.t
05/25/2020  03:49 PM               575 sociology-jstor-basicall.doc ___ fy
05/25/2020  03:50 PM         7,507,041 sociology-jstor-basicall.doc ___ fy.t
05/25/2020  03:49 PM           148,492 sociology-jstor-basicall.doc ___ t
05/25/2020  03:51 PM         4,270,394 sociology-jstor-basicall.ind ___ c
05/25/2020  03:51 PM        35,339,716 sociology-jstor-basicall.ind ___ c.c
05/25/2020  03:51 PM        41,763,540 sociology-jstor-basicall.ind ___ c.c.fy
05/25/2020  03:51 PM        42,567,375 sociology-jstor-basicall.ind ___ c.fa
05/25/2020  03:51 PM        19,820,911 sociology-jstor-basicall.ind ___ c.fj
05/25/2020  03:51 PM        22,696,881 sociology-jstor-basicall.ind ___ c.fy
05/25/2020  03:51 PM         1,323,064 sociology-jstor-basicall.ind ___ fa
05/25/2020  03:51 PM         4,155,456 sociology-jstor-basicall.ind ___ fa.fj.fy
05/25/2020  03:51 PM             1,574 sociology-jstor-basicall.ind ___ fj
05/25/2020  03:51 PM            88,001 sociology-jstor-basicall.ind ___ fj.fy
05/25/2020  03:51 PM         6,081,926 sociology-jstor-basicall.ind ___ fj.t
05/25/2020  03:51 PM               586 sociology-jstor-basicall.ind ___ fy
05/25/2020  03:51 PM         7,512,908 sociology-jstor-basicall.ind ___ fy.t
05/25/2020  03:51 PM           148,798 sociology-jstor-basicall.ind ___ t
05/25/2020  04:03 PM            83,037 sociology-jstor-basicall.t.top1
05/25/2020  04:22 PM           497,834 sociology-jstor-basicall.t.ysum
06/01/2020  02:03 PM           140,449 sociology-wos.c.top1
06/01/2020  02:01 PM        23,696,014 sociology-wos.c.ysum
06/08/2020  01:47 PM        24,501,432 sociology-wos.doc - c.fa - sparse
06/08/2020  01:42 PM        11,630,895 sociology-wos.doc - c.fy - sparse
05/27/2020  01:41 PM                 6 sociology-wos.doc ___ a
06/04/2020  03:42 PM         5,357,389 sociology-wos.doc ___ c
06/04/2020  03:42 PM         3,427,063 sociology-wos.doc ___ c.c
06/04/2020  03:42 PM        17,892,840 sociology-wos.doc ___ c.fj
06/04/2020  03:42 PM        16,668,797 sociology-wos.doc ___ c.fy
06/04/2020  03:42 PM        32,201,165 sociology-wos.doc ___ c.fy.j
06/04/2020  03:42 PM         1,335,423 sociology-wos.doc ___ fa
06/04/2020  03:42 PM        47,014,569 sociology-wos.doc ___ fa.c
06/04/2020  03:42 PM         5,505,482 sociology-wos.doc ___ fa.fj
05/31/2020  01:00 PM         7,707,926 sociology-wos.doc ___ fa.fj.fy
06/04/2020  03:42 PM         4,059,576 sociology-wos.doc ___ fa.fy
06/04/2020  03:42 PM           851,294 sociology-wos.doc ___ ffa
06/04/2020  03:42 PM        27,863,159 sociology-wos.doc ___ ffa.c
06/04/2020  03:42 PM         4,055,570 sociology-wos.doc ___ ffa.fj
06/04/2020  03:42 PM         2,424,702 sociology-wos.doc ___ ffa.fy
06/04/2020  03:42 PM             2,507 sociology-wos.doc ___ fj
06/04/2020  03:42 PM           153,609 sociology-wos.doc ___ fj.fy
06/04/2020  03:42 PM        13,300,191 sociology-wos.doc ___ fj.ta
06/04/2020  03:42 PM           265,092 sociology-wos.doc ___ fj.ty
06/04/2020  03:42 PM               618 sociology-wos.doc ___ fy
06/04/2020  03:42 PM        12,740,519 sociology-wos.doc ___ fy.ta
06/04/2020  03:42 PM            93,621 sociology-wos.doc ___ fy.ty
06/04/2020  03:42 PM           967,741 sociology-wos.doc ___ ta
06/04/2020  03:42 PM             1,102 sociology-wos.doc ___ ty
06/04/2020  03:42 PM           136,555 sociology-wos.doc ___ ty.ty
06/01/2020  02:03 PM            79,118 sociology-wos.fa.top1
06/01/2020  02:02 PM         1,008,295 sociology-wos.fa.ysum
06/04/2020  03:43 PM           549,464 sociology-wos.ffa.ysum
06/04/2020  03:43 PM            56,046 sociology-wos.included_citations
05/29/2020  11:03 AM             2,291 sociology-wos.included_journals
06/04/2020  03:42 PM         5,357,393 sociology-wos.ind ___ c
06/04/2020  03:42 PM         3,427,070 sociology-wos.ind ___ c.c
06/04/2020  03:42 PM        47,014,569 sociology-wos.ind ___ c.fa
06/04/2020  03:42 PM        27,863,159 sociology-wos.ind ___ c.ffa
06/04/2020  03:42 PM        17,892,843 sociology-wos.ind ___ c.fj
06/04/2020  03:42 PM        16,668,797 sociology-wos.ind ___ c.fy
06/04/2020  03:42 PM        32,201,165 sociology-wos.ind ___ c.fy.j
06/04/2020  03:42 PM         1,336,972 sociology-wos.ind ___ fa
06/04/2020  03:42 PM         5,505,712 sociology-wos.ind ___ fa.fj
05/31/2020  01:00 PM         7,707,926 sociology-wos.ind ___ fa.fj.fy
06/04/2020  03:42 PM         4,059,580 sociology-wos.ind ___ fa.fy
06/04/2020  03:42 PM           851,918 sociology-wos.ind ___ ffa
06/04/2020  03:42 PM         4,055,622 sociology-wos.ind ___ ffa.fj
06/04/2020  03:42 PM         2,424,702 sociology-wos.ind ___ ffa.fy
06/04/2020  03:42 PM             2,511 sociology-wos.ind ___ fj
06/04/2020  03:42 PM           155,385 sociology-wos.ind ___ fj.fy
06/04/2020  03:42 PM        13,300,273 sociology-wos.ind ___ fj.ta
06/04/2020  03:42 PM           265,894 sociology-wos.ind ___ fj.ty
06/04/2020  03:42 PM               639 sociology-wos.ind ___ fy
06/04/2020  03:42 PM        12,740,530 sociology-wos.ind ___ fy.ta
06/04/2020  03:42 PM            93,761 sociology-wos.ind ___ fy.ty
06/04/2020  03:42 PM           967,939 sociology-wos.ind ___ ta
06/04/2020  03:42 PM             1,102 sociology-wos.ind ___ ty
06/04/2020  03:42 PM           136,737 sociology-wos.ind ___ ty.ty
06/04/2020  03:42 PM         5,468,877 sociology-wos.pubyears
06/01/2020  02:03 PM            57,447 sociology-wos.ta.top1
06/01/2020  02:02 PM         7,639,907 sociology-wos.ta.ysum
05/31/2020  12:46 PM        14,029,016 sociology-wos-all.c.ysum
05/31/2020  12:34 PM        79,218,111 sociology-wos-all.doc ___ c
05/31/2020  12:34 PM         8,933,725 sociology-wos-all.doc ___ c.c
05/31/2020  12:34 PM             2,507 sociology-wos-all.doc ___ fj
05/31/2020  12:34 PM           154,304 sociology-wos-all.doc ___ fj.fy
05/31/2020  12:34 PM               675 sociology-wos-all.doc ___ fy
05/31/2020  12:34 PM             1,280 sociology-wos-all.doc ___ ty
05/31/2020  12:34 PM           152,587 sociology-wos-all.doc ___ ty.ty
05/31/2020  12:50 PM         5,739,910 sociology-wos-all.groups
05/29/2020  11:03 AM             2,349 sociology-wos-all.included_journals
05/31/2020  12:34 PM        79,218,114 sociology-wos-all.ind ___ c
05/31/2020  12:34 PM         8,933,859 sociology-wos-all.ind ___ c.c
05/31/2020  12:34 PM             2,541 sociology-wos-all.ind ___ fj
05/31/2020  12:34 PM           157,362 sociology-wos-all.ind ___ fj.fy
05/31/2020  12:34 PM               743 sociology-wos-all.ind ___ fy
05/31/2020  12:34 PM             1,334 sociology-wos-all.ind ___ ty
05/31/2020  12:34 PM           153,762 sociology-wos-all.ind ___ ty.ty
05/31/2020  12:34 PM        80,904,384 sociology-wos-all.pubyears
             150 File(s)  1,725,888,451 bytes
               3 Dir(s)  38,688,899,072 bytes free
In [14]:
!osf -p 9vx4y -u amcgail2@gmail.com upload -r . variables
In [ ]:
/v2/nodes/9vx4y/files/osfstorage/5eded7eb8b542601798b6842/
In [41]:
 
In [45]:
download_file(url, outfn)
---------------------------------------------------------------------------
HTTPError                                 Traceback (most recent call last)
<ipython-input-45-14bb45ab681a> in <module>
     16     return outfn
     17 
---> 18 download_file(url, outfn)

<ipython-input-45-14bb45ab681a> in download_file(url, outfn)
      7     # NOTE the stream=True parameter below
      8     with requests.get(url, stream=True) as r:
----> 9         r.raise_for_status()
     10         with open(outfn, 'wb') as f:
     11             for chunk in r.iter_content(chunk_size=8192):

c:\users\amcga\envs\citation-deaths\lib\site-packages\requests\models.py in raise_for_status(self)
    939 
    940         if http_error_msg:
--> 941             raise HTTPError(http_error_msg, response=self)
    942 
    943     def close(self):

HTTPError: 404 Client Error: NOT FOUND for url: https://osf.io/9vx4y/download
In [10]:
class osf:

    import requests
    nodes = ['9vx4y']
    provider = 'osfstorage'

    def get_databases():
        self.databases = {}
        for node in self.nodes:
            url = 'https://api.osf.io/v2/nodes/{node}/files/5eded795c67d30014e1f3714'.format(
                node=node,
                provider=self.provider
            )
            print(url)

            r = requests.get(url)
            self.databases[node] = loads( r.content.decode('utf8') )
            
        
https://api.osf.io/v2/nodes/9vx4y/files/osfstorage/
In [33]:
url = 'https://api.osf.io/v2/nodes/{node}/files/osfstorage/5eded7eb8b542601798b6842/'.format(
    node=node,
    provider=provider
)
print(url)

r = requests.get(url)
https://api.osf.io/v2/nodes/9vx4y/files/osfstorage/5eded7eb8b542601798b6842/
In [22]:
node = '9vx4y'
In [34]:
from json import loads
a = loads( r.content.decode('utf8') )
In [38]:
a['data'][0]['attributes']['name']
Out[38]:
'sociology-wos-all.c.ysum'
In [36]:
len(a['data'])
Out[36]:
10
In [21]:
a['data'][2]
Out[21]:
{'id': '5eded795c67d30014e1f3714',
 'type': 'files',
 'attributes': {'guid': None,
  'checkout': None,
  'name': 'sociology-wos',
  'kind': 'folder',
  'path': '/5eded795c67d30014e1f3714/',
  'size': None,
  'provider': 'osfstorage',
  'materialized_path': '/sociology-wos/',
  'last_touched': None,
  'date_modified': None,
  'date_created': None,
  'extra': {'hashes': {'md5': None, 'sha256': None}},
  'tags': [],
  'current_user_can_comment': False,
  'current_version': 1},
 'relationships': {'parent_folder': {'links': {'related': {'href': 'https://api.osf.io/v2/files/5dfe887b5747bd002b748a3e/',
     'meta': {}}},
   'data': {'id': '5dfe887b5747bd002b748a3e', 'type': 'files'}},
  'files': {'links': {'related': {'href': 'https://api.osf.io/v2/nodes/9vx4y/files/osfstorage/5eded795c67d30014e1f3714/',
     'meta': {}}}},
  'node': {'links': {'related': {'href': 'https://api.osf.io/v2/nodes/9vx4y/',
     'meta': {}}},
   'data': {'id': '9vx4y', 'type': 'nodes'}},
  'target': {'links': {'related': {'href': 'https://api.osf.io/v2/nodes/9vx4y/',
     'meta': {'type': 'node'}}},
   'data': {'type': 'node', 'id': '9vx4y'}}},
 'links': {'info': 'https://api.osf.io/v2/files/5eded795c67d30014e1f3714/',
  'move': 'https://files.osf.io/v1/resources/9vx4y/providers/osfstorage/5eded795c67d30014e1f3714/',
  'upload': 'https://files.osf.io/v1/resources/9vx4y/providers/osfstorage/5eded795c67d30014e1f3714/',
  'delete': 'https://files.osf.io/v1/resources/9vx4y/providers/osfstorage/5eded795c67d30014e1f3714/',
  'new_folder': 'https://files.osf.io/v1/resources/9vx4y/providers/osfstorage/5eded795c67d30014e1f3714/?kind=folder',
  'self': 'https://api.osf.io/v2/files/5eded795c67d30014e1f3714/'}}
In [18]:
a['data'][0]['relationships']
Out[18]:
{'parent_folder': {'links': {'related': {'href': 'https://api.osf.io/v2/files/5dfe887b5747bd002b748a3e/',
    'meta': {}}},
  'data': {'id': '5dfe887b5747bd002b748a3e', 'type': 'files'}},
 'files': {'links': {'related': {'href': 'https://api.osf.io/v2/nodes/9vx4y/files/osfstorage/5eded7478b542601748b4bdb/',
    'meta': {}}}},
 'node': {'links': {'related': {'href': 'https://api.osf.io/v2/nodes/9vx4y/',
    'meta': {}}},
  'data': {'id': '9vx4y', 'type': 'nodes'}},
 'target': {'links': {'related': {'href': 'https://api.osf.io/v2/nodes/9vx4y/',
    'meta': {'type': 'node'}}},
  'data': {'type': 'node', 'id': '9vx4y'}}}
In [9]:
a['data'][0]['attributes']['name']
Out[9]:
'sociology-jstor-basicall'
In [7]:
len(a['data'])
Out[7]:
4
In [30]:
print('c:\\users\\amcga\\envs\\citation-deaths\\lib\\site-packages\\knowknow')
c:\users\amcga\envs\citation-deaths\lib\site-packages\knowknow
In [19]:
variable_name = "sociology-wos.ta.ysum"
project='9vx4y'
cmd = ['osf', '-p', project, 'fetch', 'variables/%s'%variable_name, 'testmeplease']
print(" ".join(cmd))
osf -p 9vx4y fetch variables/sociology-wos.ta.ysum testmeplease
In [16]:
BASEDIR
Out[16]:
'c:\\users\\amcga\\envs\\citation-deaths\\lib\\site-packages\\knowknow'