Skip to main content

Simple way to handle sharepoint with python

Project description

Simple way to handle sharepoint with python. Provides the ability to upload files and directories.

Installation

install the latest stable version using pip

$ pip install simple-sharepoint

Usage

from simple_sharepoint.client import Client

client_id = < CLIENT_ID >
client_secret = < CLIENT_SECRET >
base_url = < BASE URL >

c = Client(client_id, client_secret, base_url)
  • See the link below for instructions on creating CLIENT_ID and CLIENT_SECRET
    Make Token

  • BASE_URL refers to the main URL of the sharepoint.
    ( format ) https://<SHAREPOINT_DOMAIN>/sites/<SHAREPOINT_SITE>
    ( ex ) https://test.sharepoint.com/sites/testsite

Functions

upload_file

A function that uploads a specific file to sharepoint.

default_path = < SHAREPOINT_BASE_PATH >
src = < LOCAL_FILE_PATH >
dst = default_path + < SHAREPOINT_TARGET_PATH >

upload_file(src, dst)
  • SHAREPOINT_BASE_PATH refers to the default path for a sharepoint document entry.
    ( format ) /sites/<SHAREPOINT_SITE>/Shared Documents
    ( ex ) /sites/testsite/Shared Documents

  • LOCAL_FILE_PATH means the path to the file to be uploaded.
    ( ex ) /home/ubuntu/test.txt

  • SHAREPOINT_TARGET_PATH means the actual path to be uploaded to sharepoint.
    Think of the document menu in sharepoint as the root directory and enter the path thereafter.
    You do not need to include the file name.
    ( ex ) excel/example

  • If you run it as above, it will be uploaded as below.
    /sites/testsite/Shared Documents/excel/example/test.txt

upload_dir

A function that uploads a particular directory and all its contents under the directory to sharepoint.

default_path = < SHAREPOINT_BASE_PATH >
src = < LOCAL_DIR_PATH >
dst = default_path + < SHAREPOINT_TARGET_PATH >

upload_dir(src, dst)
  • SHAREPOINT_BASE_PATH, SHAREPIONT_TARGET_PATH See item upload_file

  • LOCAL_DIR_PATH means the path to the directory to be uploaded.
    ( ex ) /home/ubuntu/files

download_file

A function that downloads a specific file from the sharepoint.

default_path = < SHAREPOINT_BASE_PATH >
src = default_path + < SHAREPOINT_TARGET_PATH >
dst = < LOCAL_FILE_PATH >

download_file(src, dst)
  • SHAREPOINT_BASE_PATH, SHAREPIONT_TARGET_PATH See item upload_file

  • The download_file function requires you to specify the file name to be stored in LOCAL_FILE_PATH. ( ex ) /home/ubuntu/files/test.txt

download_dir

A function that downloads a particular directory in the sharepoint and all the contents under it.

default_path = < SHAREPOINT_BASE_PATH >
src = default_path + < SHAREPOINT_TARGET_PATH >
dst = < LOCAL_DIR_PATH >

download_dir(src, dst)
  • SHAREPOINT_BASE_PATH, SHAREPIONT_TARGET_PATH, LOCAL_DIR_PATH See item upload_dir

list_dir

A function that listing a particular directory in the sharepoint and all the contents under it.

default_path = < SHAREPOINT_BASE_PATH >
src = default_path + < SHAREPOINT_TARGET_PATH >

list_dir(src)
  • SHAREPOINT_BASE_PATH, SHAREPIONT_TARGET_PATH See item upload_dir

Use console scripts

simple-sharepoint-cli < FILE_PATH > --client_id < CLIENT_ID > --client-secret < CLIENT_SECRET > --base-url < BASE_URL > --default_path < DEFAULT_PATH > --remote-dir < REMOTE_DIR >
  • CLIENT_ID, CLIENT_SECRET, BASE_URL See item Usage.
  • DEFAULT_PATH See upload_dir. same SHAREPOINT_BASE_PATH
  • REMOTE_DIR See upload_dir. same SHAREPOINT_TARGET_PATH

Third Party Libraries and Dependencies

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

simple_sharepoint-0.1.6-py3-none-any.whl (5.2 kB view details)

Uploaded Python 3

File details

Details for the file simple_sharepoint-0.1.6-py3-none-any.whl.

File metadata

File hashes

Hashes for simple_sharepoint-0.1.6-py3-none-any.whl
Algorithm Hash digest
SHA256 4b462b6621ce4cabc8bd7c2e79ada4484c18ad7468ab2d1b3dcf3461d3678fe2
MD5 7a9c2b89914158ec72888f73be18560f
BLAKE2b-256 f2a901d56f3ece12944c9e07d2dbeb99dd15e6af224494cee559f6b7e3867bc6

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page